本文整理汇总了PHP中CHtml::activeHiddenField方法的典型用法代码示例。如果您正苦于以下问题:PHP CHtml::activeHiddenField方法的具体用法?PHP CHtml::activeHiddenField怎么用?PHP CHtml::activeHiddenField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CHtml
的用法示例。
在下文中一共展示了CHtml::activeHiddenField方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* ### .run()
*
* Widget's run function
*/
public function run()
{
list($name, $id) = $this->resolveNameID();
$this->registerClientScript($id);
$this->htmlOptions['id'] = $id;
$this->htmlOptions['readonly'] = "readonly";
$radius = $this->displayInput ? "" : "border-radius:4px;";
// Do we have a model?
echo '<div class="input-append color" data-color="' . $this->value . '" data-color-format="rgb" id="' . $id . '_color">';
if ($this->hasModel()) {
if ($this->form) {
if ($this->displayInput) {
echo $this->form->textField($this->model, $this->attribute, $this->htmlOptions);
} else {
echo $this->form->hiddenField($this->model, $this->attribute, $this->htmlOptions);
}
} else {
if ($this->displayInput) {
echo CHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions);
} else {
echo CHtml::activeHiddenField($this->model, $this->attribute, $this->htmlOptions);
}
}
} else {
if ($this->displayInput) {
echo CHtml::textField($name, $this->value, $this->htmlOptions);
} else {
echo CHtml::hiddenField($name, $this->value, $this->htmlOptions);
}
}
echo '<span class="add-on" style="' . $radius . '"><i style="background-color: ' . $this->value . '"></i></span></div>';
}
示例2: capturePosition
/**
* Capture the latitude and longitude of the marker to a model.
*
* @param CModel $model Model object
* @param string $lat Attribute name for latitude
* @param string $lng Attribute name for longitude
* @param array $options Options to set :<ul>
* <li>'visible' - show the input fields
* <li>'nocallback' - do not update on callback
* <li>'nodragend' - do not update on dragend
* <li>'drag' - update on drag
* </ul>
*/
public function capturePosition(CModel $model, $lat, $lng, array $options = array())
{
// field options
if (in_array('visible', $options)) {
echo CHtml::activeLabelEx($model, $lat), CHtml::activeTextField($model, $lat);
echo '<br>';
echo CHtml::activeLabelEx($model, $lng), CHtml::activeTextField($model, $lng);
} else {
echo CHtml::activeHiddenField($model, $lat), CHtml::activeHiddenField($model, $lng);
}
$latId = CHtml::activeId($model, $lat);
$lngId = CHtml::activeId($model, $lng);
// update function
$jsFunction = "function captureMarkerPosition(marker){\$('#{$latId}').val(marker.getPosition().lat());\$('#{$lngId}').val(marker.getPosition().lng());}";
Yii::app()->getClientScript()->registerScript(__CLASS__ . '#capturePosition', $jsFunction, CClientScript::POS_END);
// event options
if (!in_array('nocallback', $options)) {
$this->addCallback('function(result){captureMarkerPosition(result);}');
}
if (!in_array('nodragend', $options)) {
$this->addEvent('dragend', 'function(result){captureMarkerPosition(result);}');
}
if (in_array('drag', $options)) {
$this->addEvent('drag', 'function(result){captureMarkerPosition(result);}');
}
$this->addEvent('position_changed', 'function(result){captureMarkerPosition(result);}');
}
示例3: renderField
/**
* Renders the input file field
*/
public function renderField()
{
list($name, $id) = $this->resolveNameID();
TbArray::defaultValue('id', $id, $this->htmlOptions);
TbArray::defaultValue('name', $name, $this->htmlOptions);
TbHtml::addCssClass('bfh-selectbox', $this->wrapperOptions);
echo CHtml::openTag('div', $this->wrapperOptions);
if ($this->hasModel()) {
echo CHtml::activeHiddenField($this->model, $this->attribute, $this->htmlOptions);
$value = $this->model->{$this->attribute};
$valueText = $value && isset($this->data[$value]) ? $this->data[$value] : ' ';
} else {
echo CHtml::hiddenField($name, $this->value, $this->htmlOptions);
$value = $this->value;
$valueText = $value && isset($this->data[$value]) ? $this->data[$value] : ' ';
}
echo CHtml::openTag('a', array('class' => 'bfh-selectbox-toggle', 'role' => 'button', 'data-toggle' => 'bfh-selectbox', 'href' => '#'));
echo CHtml::tag('span', array('class' => 'bfh-selectbox-option ' . $this->size, 'data-option' => $value), $valueText);
echo CHtml::tag('b', array('class' => 'caret'), ' ');
echo CHtml::closeTag('a');
echo CHtml::openTag('div', array('class' => 'bfh-selectbox-options'));
if ($this->displayFilter) {
echo '<input type="text" class="bfh-selectbox-filter">';
}
$items = array();
foreach ($this->data as $key => $item) {
$items[] = CHtml::tag('a', array('tabindex' => '-1', 'href' => '#', 'data-option' => $key), $item);
}
echo CHtml::tag('ul', array('role' => 'options'), '<li>' . implode('</li><li>', $items) . '</li>');
echo CHtml::closeTag('div');
echo CHtml::closeTag('div');
}
示例4: run
/**
* Run this widget.
* This method registers necessary javascript and renders the needed HTML code.
*/
public function run()
{
list($name, $id) = $this->resolveNameID();
if (isset($this->htmlOptions['id'])) {
$id = $this->htmlOptions['id'];
} else {
$this->htmlOptions['id'] = $id;
}
if (isset($this->htmlOptions['name'])) {
$name = $this->htmlOptions['name'];
} else {
$this->htmlOptions['name'] = $name;
}
if ($this->hasModel() === false && $this->value !== null) {
$this->options['value'] = $this->value;
}
if ($this->hasModel()) {
echo CHtml::activeHiddenField($this->model, $this->attribute, $this->htmlOptions);
} else {
echo CHtml::hiddenField($name, $this->value, $this->htmlOptions);
}
$idHidden = $this->htmlOptions['id'];
$nameHidden = $this->htmlOptions['name'];
$this->htmlOptions['id'] = $idHidden . '_slider';
$this->htmlOptions['name'] = $nameHidden . '_slider';
echo CHtml::openTag($this->tagName, $this->htmlOptions);
echo CHtml::closeTag($this->tagName);
$this->options[$this->event] = 'js:function(event, ui) { jQuery(\'#' . $idHidden . '\').val(ui.value); }';
$options = empty($this->options) ? '' : CJavaScript::encode($this->options);
$js = "jQuery('#{$id}_slider').slider({$options});\n";
Yii::app()->getClientScript()->registerScript(__CLASS__ . '#' . $id, $js);
}
示例5: showLangModal
public function showLangModal()
{
$language = Yii::app()->params['language'];
$this->beginWidget('bootstrap.widgets.TbModal', array('id' => $this->modalId, 'htmlOptions' => array('style' => 'margin-top:-200px;', 'backdrop' => 'static')));
echo "<div class=\"modal-header\">\n <h4 style=\"width:30%;display: inline-block;\">翻译</h4> \n <span id='" . $this->modalId . "message' style=\"margin-left:30px;color:red;\"></span>\n </div>";
echo "<div id='" . $this->modalId . "ModalBody' class=\"modal-body\" style=\"text-align:center\">";
$tableName = $this->model->tableName();
$attribute = $this->attribute;
echo CHtml::hiddenField('tableName', $tableName);
echo CHtml::hiddenField('attribute', $attribute);
$pk = $this->model->primaryKey;
echo CHtml::activeHiddenField($this->model, $this->model->pk, array('name' => 'pk'));
$result = Translation::model()->find('model=:tableName and pk=:pk and attribute=:attribute', array(':tableName' => $tableName, ':pk' => $pk, ':attribute' => $attribute));
$data = json_decode($result->data);
foreach ($language as $key => $value) {
if (strtolower($key) == 'zh_cn') {
continue;
}
echo "<div><span style='width:80px !important;display: inline-block;'>" . $value . '</span>' . CHtml::textField($key, $data->{$key}) . "</div>";
}
echo "</div>";
echo "<div class=\"modal-footer\" style=\"text-align: center;\">";
$this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'button', 'type' => 'info', 'label' => '保存', 'htmlOptions' => array('id' => $this->modalId . 'save')));
echo " ";
$this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'button', 'label' => '取消', 'htmlOptions' => array("data-dismiss" => "modal", 'id' => $this->modalId . 'back')));
echo "</div>";
$this->endWidget();
}
示例6: run
public function run()
{
list($name, $id) = $this->resolveNameID();
if (isset($this->htmlOptions['id'])) {
$id = $this->htmlOptions['id'];
} else {
$this->htmlOptions['id'] = $id;
}
if (isset($this->htmlOptions['name'])) {
$name = $this->htmlOptions['name'];
}
if ($this->flat === false) {
if ($this->hasModel()) {
echo CHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions);
} else {
echo CHtml::textField($name, $this->value, $this->htmlOptions);
}
} else {
if ($this->hasModel()) {
echo CHtml::activeHiddenField($this->model, $this->attribute, $this->htmlOptions);
$attribute = $this->attribute;
$this->options['defaultDate'] = $this->model->{$attribute};
} else {
echo CHtml::hiddenField($name, $this->value, $this->htmlOptions);
$this->options['defaultDate'] = $this->value;
}
if (!isset($this->options['onSelect'])) {
$this->options['onSelect'] = "js:function( selectedDate ) { jQuery('#{$id}').val(selectedDate);}";
}
$id = $this->htmlOptions['id'] = $id . '_container';
$this->htmlOptions['name'] = $name . '_container';
echo CHtml::tag('div', $this->htmlOptions, '');
}
$this->options['beforeShowDay'] = <<<EOD
js:function(date){
\tif (typeof reservedDays !== 'undefined') {
\t\tfor (i = 0; i < reservedDays.length; i++) {
\t\t\tif (date.getFullYear() == reservedDays[i][0] && date.getMonth() == reservedDays[i][1] - 1 && date.getDate() == reservedDays[i][2])
\t\t\t{
\t\t\t\treturn [false, "datepicker-calendarDescriptionReserved"];
\t\t\t}
\t\t}
\t\treturn [true,""];
\t}
}
EOD;
$options = CJavaScript::encode($this->options);
$js = "jQuery('#{$id}').datepicker({$options});";
if ($this->language != '' && $this->language != 'en') {
$this->registerScriptFile($this->i18nScriptFile);
$js = "jQuery('#{$id}').datepicker(jQuery.extend({showMonthAfterYear:false}, jQuery.datepicker.regional['{$this->language}'], {$options}));";
}
$cs = Yii::app()->getClientScript();
if (isset($this->defaultOptions)) {
$this->registerScriptFile($this->i18nScriptFile);
$cs->registerScript(__CLASS__, $this->defaultOptions !== null ? 'jQuery.datepicker.setDefaults(' . CJavaScript::encode($this->defaultOptions) . ');' : '');
}
$cs->registerScript(__CLASS__ . '#' . $id, $js);
}
示例7: renderField
/**
* Renders the select2 field
*/
public function renderField()
{
if ($this->hasModel()) {
echo $this->asDropDownList ? \CHtml::activeDropDownList($this->model, $this->attribute, $this->data, $this->options) : \CHtml::activeHiddenField($this->model, $this->attribute);
} else {
echo $this->asDropDownList ? \CHtml::dropDownList($this->options['name'], $this->value, $this->data, $this->options) : \CHtml::hiddenField($this->options['name'], $this->value);
}
}
示例8: captureZoom
/**
* Capture the map's zoom level to a field
*
* @param CModel $model Model containing the attribute
* @param string $attribute Name of the model's attribute
* @param boolean $generate Whether to generate the field
* @param array $htmlOptions HTML options for the field
*/
public function captureZoom(CModel $model, $attribute, $generate = true, array $htmlOptions = array())
{
if ($generate) {
echo CHtml::activeHiddenField($model, $attribute, $htmlOptions);
}
$attId = CHtml::activeId($model, $attribute);
$this->addEvent('zoom_changed', "function(map){\$('#{$attId}').val(map.getZoom());}");
}
示例9: run
/**
* Renders the widget.
* @return void
*/
public function run()
{
if ($this->hidden) {
echo CHtml::activeHiddenField($this->model, $this->attribute, $this->htmlOptions);
} else {
echo CHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions);
}
}
示例10: display
public function display(array $attr = null)
{
if ($this->_value != "") {
CHtml::hiddenField($this->_name, $this->_value);
} else {
CHtml::activeHiddenField($this->_name, $this->_model);
}
}
示例11: run
public function run()
{
list($name, $id) = $this->resolveNameID();
if (isset($this->htmlOptions['id'])) {
$id = $this->htmlOptions['id'];
} else {
$this->htmlOptions['id'] = $id;
}
if (isset($this->htmlOptions['name'])) {
$name = $this->htmlOptions['name'];
} else {
$this->htmlOptions['name'] = $name;
}
$contHtmlOptions = $this->htmlOptions;
$contHtmlOptions['id'] = $id . 'container';
echo CHtml::openTag('div', $contHtmlOptions);
$inputOptions = array('id' => $id);
if ($this->hasModel()) {
echo CHtml::activeHiddenField($this->model, $this->attribute, $inputOptions);
$imgPath = $this->model->{$this->attribute};
} else {
echo CHtml::hiddenField($name, $this->value, $inputOptions);
$imgPath = $this->value;
}
if (!@getimagesize($imgPath)) {
$imgPath = $this->assetsDir . '/images/no-photo.gif';
}
echo CHtml::image($imgPath, 'preview', array('id' => 'image-preview-' . $id, 'style' => 'max-width: 120px; max-height: 120px; display: block; margin-bottom: 10px;'));
echo CHtml::button('Browse', array('id' => $id . 'browse', 'class' => 'btn'));
echo CHtml::closeTag('div');
$settings = array_merge(array('places' => "", 'rememberLastDir' => false), $this->settings);
$settings['dialog'] = array('zIndex' => 400001, 'width' => 900, 'modal' => true, 'title' => "Files");
$settings['editorCallback'] = 'js:function(url) {
$(\'#\'+aFieldId).attr(\'value\',url);
$(\'#image-preview-\'+aFieldId).attr(\'src\',url);
}';
$settings['closeOnEditorCallback'] = true;
$connectorUrl = CJavaScript::encode($this->settings['url']);
$settings = CJavaScript::encode($settings);
$script = <<<EOD
window.elfinderBrowse = function(field_id, connector) {
var aFieldId = field_id, aWin = this;
if(\$("#elFinderBrowser").length == 0) {
\$("body").append(\$("<div/>").attr("id", "elFinderBrowser"));
var settings = {$settings};
settings["url"] = connector;
\$("#elFinderBrowser").elfinder(settings);
}
else {
\$("#elFinderBrowser").elfinder("open", connector);
}
}
EOD;
$cs = Yii::app()->getClientScript();
$cs->registerScript('ServerFileInput#global', $script);
$js = '$("#' . $id . 'browse").click(function(){window.elfinderBrowse("' . $id . '", ' . $connectorUrl . ')});';
$cs->registerScript('ServerFileInput#' . $id, $js);
}
示例12: run
public function run()
{
if ($this->selector == null) {
list($this->name, $this->id) = $this->resolveNameId();
$this->selector = '#' . $this->id;
if (isset($this->htmlOptions['placeholder'])) {
$this->options['placeholder'] = $this->htmlOptions['placeholder'];
}
if (!isset($this->htmlOptions['multiple'])) {
$data = array();
if (isset($this->options['placeholder'])) {
$data[''] = '';
}
$this->data = $data + $this->data;
}
if ($this->hasModel()) {
if (isset($this->options['ajax'])) {
echo CHtml::activeHiddenField($this->model, $this->attribute, $this->htmlOptions);
} else {
echo CHtml::activeDropDownList($this->model, $this->attribute, $this->data, $this->htmlOptions);
}
} elseif (!isset($this->options['ajax'])) {
$this->htmlOptions['id'] = $this->id;
echo CHtml::dropDownList($this->name, $this->value, $this->data, $this->htmlOptions);
} else {
echo CHtml::hiddenField($this->name, $this->value, $this->htmlOptions);
}
}
$bu = Yii::app()->assetManager->publish(dirname(__FILE__) . '/assets/');
$cs = Yii::app()->clientScript;
//$cs->registerCssFile($bu . '/select2.css');
if (YII_DEBUG) {
$cs->registerScriptFile($bu . '/select2.js');
} else {
$cs->registerScriptFile($bu . '/select2.min.js');
}
if ($this->sortable) {
$cs->registerCoreScript('jquery.ui');
}
$options = CJavaScript::encode(CMap::mergeArray($this->defaultOptions, $this->options));
ob_start();
echo "jQuery('{$this->selector}').select2({$options})";
foreach ($this->events as $event => $handler) {
echo ".on('{$event}', " . CJavaScript::encode($handler) . ")";
}
echo ';';
if ($this->sortable) {
echo <<<JavaScript
jQuery('{$this->selector}').select2("container").find("ul.select2-choices").sortable({
\tcontainment: 'parent',
\tstart: function() { jQuery('{$this->selector}').select2("onSortStart"); },
\tupdate: function() { jQuery('{$this->selector}').select2("onSortEnd"); }
});
JavaScript;
}
$cs->registerScript(__CLASS__ . '#' . $this->id, ob_get_clean());
}
示例13: run
public function run()
{
parent::run();
echo CHtml::activeHiddenField($this->model, $this->attributeLat, $this->htmlOptions);
echo CHtml::activeHiddenField($this->model, $this->attributeLon, $this->htmlOptions);
echo CHtml::activeHiddenField($this->model, $this->attributeZoom, $this->htmlOptions);
// echo CHtml::activeTextField($this->model, $this->attributeLat, $this->htmlOptions);
// echo CHtml::activeTextField($this->model, $this->attributeLon, $this->htmlOptions);
// echo CHtml::activeTextField($this->model, $this->attributeZoom, $this->htmlOptions);
}
示例14: run
/**
* Run this widget.
* This method registers necessary javascript and renders the needed HTML code.
*/
public function run()
{
list($name, $id) = $this->resolveNameID();
if (isset($this->htmlOptions['id'])) {
$id = $this->htmlOptions['id'];
} else {
$this->htmlOptions['id'] = $id;
}
if (isset($this->htmlOptions['name'])) {
$name = $this->htmlOptions['name'];
}
if ($this->flat === false) {
if ($this->hasModel()) {
echo CHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions);
} else {
echo CHtml::textField($name, $this->value, $this->htmlOptions);
}
} else {
if ($this->hasModel()) {
echo CHtml::activeHiddenField($this->model, $this->attribute, $this->htmlOptions);
$attribute = $this->attribute;
$this->options['defaultDate'] = $this->model->{$attribute};
} else {
echo CHtml::hiddenField($name, $this->value, $this->htmlOptions);
$this->options['defaultDate'] = $this->value;
}
$this->options['altField'] = '#' . $id;
$id = $this->htmlOptions['id'] = $id . '_container';
$this->htmlOptions['name'] = $name . '_container';
echo CHtml::tag('div', $this->htmlOptions, '');
}
$options = CJavaScript::encode($this->options);
$js = "jQuery('#{$id}').datetimepicker({$options});";
$assetsDir = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets';
$assets = Yii::app()->assetManager->publish($assetsDir);
$i18nScriptFile = 'jquery-ui-timepicker-' . $this->language . '.js';
$i18nScriptPath = $assetsDir . DIRECTORY_SEPARATOR . 'localization' . DIRECTORY_SEPARATOR . $i18nScriptFile;
$cs = Yii::app()->clientScript;
$cs->registerScriptFile($assets . '/jquery-ui-timepicker-addon.js', CClientScript::POS_END);
if ($this->language != '' && $this->language != 'en') {
$this->registerScriptFile($this->i18nScriptFile);
if (file_exists($i18nScriptPath)) {
$cs->registerScriptFile($assets . '/localization/' . $i18nScriptFile, CClientScript::POS_END);
}
$js = "jQuery('#{$id}').datetimepicker(jQuery.extend(jQuery.datepicker.regional['{$this->language}'], {$options}));";
}
if (isset($this->defaultOptions)) {
$this->registerScriptFile($this->i18nScriptFile);
if (file_exists($i18nScriptPath)) {
$cs->registerScriptFile($assets . '/localization/' . $i18nScriptFile, CClientScript::POS_END);
}
$cs->registerScript(__CLASS__, $this->defaultOptions !== null ? 'jQuery.datetimepicker.setDefaults(' . CJavaScript::encode($this->defaultOptions) . ');' : '');
}
$cs->registerScript(__CLASS__ . '#' . $id, $js);
}
示例15: renderField
/**
* Renders the select2 field
*/
public function renderField()
{
list($name, $id) = $this->resolveNameID();
TbArray::defaultValue('id', $id, $this->htmlOptions);
TbArray::defaultValue('name', $name, $this->htmlOptions);
if ($this->hasModel()) {
echo $this->asDropDownList ? CHtml::activeDropDownList($this->model, $this->attribute, $this->data, $this->htmlOptions) : CHtml::activeHiddenField($this->model, $this->attribute);
} else {
echo $this->asDropDownList ? CHtml::dropDownList($this->name, $this->value, $this->data, $this->htmlOptions) : CHtml::hiddenField($this->name, $this->value);
}
}