/** * @inheritdoc */ 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->type == static::TYPE_TEXT) { if ($this->hasModel()) { echo \CHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions); } else { echo \CHtml::textField($name, $this->value, $this->htmlOptions); } } elseif ($this->type == static::TYPE_SELECT) { if ($this->hasModel()) { echo \CHtml::activeDropDownList($this->model, $this->attribute, $this->data, $this->htmlOptions); } else { echo \CHtml::dropDownList($name, $this->value, $this->data, $this->htmlOptions); } } else { throw new \CException("Invalid field type '{$this->type}'"); } $options = !empty($this->options) ? \CJavaScript::encode($this->options) : ''; $script = "jQuery('#{$id}').select2({$options})"; foreach ($this->events as $event => $handler) { $script .= ".on('{$event}'," . \CJavaScript::encode($handler) . ")"; } $script .= ';'; \Yii::app()->clientScript->registerScript(__CLASS__ . '#' . $this->getId(), $script); $this->registerAssets(); }
public function actionGetVariations() { if (Yii::app()->request->isAjaxRequest && isset($_POST['product'])) { $product = Products::model()->findByPk($_POST['product']); echo CHtml::hiddenField('product_id', $product->product_id); if ($variations = $product->getVariations()) { foreach ($variations as $variation) { $field = "Variations[{$variation[0]->specification_id}][]"; echo '<div class="shop-variation-element">'; echo '<strong>' . CHtml::label($variation[0]->specification->title . '</strong>', $field, array('class' => 'lbl-header')); if ($variation[0]->specification->required) { echo ' <span class="required">*</span>'; } echo '<br />'; if ($variation[0]->specification->input_type == 'textfield') { echo CHtml::textField($field); } else { if ($variation[0]->specification->input_type == 'select') { // If the specification is required, preselect the first field. // Otherwise let the customer choose which one to pick // $product->variationCount > 1 ? true : false means, that the // widget should display the _absolute_ price if only 1 variation // is available, otherwise the relative (+ X $) echo CHtml::radioButtonList($field, $variation[0]->specification->required ? $variation[0]->id : null, ProductVariation::listData($variation, $product->variationCount > 1 ? true : false), array('template' => '{input} {label}', 'separator' => '<div class="clear"></div>')); } } echo '</div>'; } } } else { throw new CHttpException(404); } }
/** * 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()) { echo CHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions); } else { echo CHtml::textField($name, $this->value, $this->htmlOptions); } $options = CJavaScript::encode($this->options); $js = "jQuery('#{$id}').datepicker({$options});"; if (isset($this->language)) { $this->registerScriptFile($this->i18nScriptFile); $js = "jQuery('#{$id}').datepicker(jQuery.extend({showMonthAfterYear:false}, jQuery.datepicker.regional['{$this->language}'], {$options}));"; } $cs = Yii::app()->getClientScript(); $cs->registerScript(__CLASS__, $this->defaultOptions ? 'jQuery.datepicker.setDefaults(' . CJavaScript::encode($this->defaultOptions) . ');' : ''); $cs->registerScript(__CLASS__ . '#' . $id, $js); }
/** * @inheritdoc */ 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->hasModel()) { echo \CHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions); } else { echo \CHtml::textField($name, $this->value, $this->htmlOptions); } $options = !empty($this->options) ? \CJavaScript::encode($this->options) : ''; $script = "jQuery('#{$id}').datetimepicker({$options})"; foreach ($this->events as $event => $handler) { $script .= ".on('{$event}'," . \CJavaScript::encode($handler) . ")"; } $script .= ';'; \Yii::app()->clientScript->registerScript(__CLASS__ . '#' . $this->getId(), $script); $this->registerAssets(); }
/** *### .run() * * Runs the widget. */ public function run() { if ($this->selector) { Yii::app()->bootstrap->registerDateRangePlugin($this->selector, $this->options, $this->callback); } else { list($name, $id) = $this->resolveNameID(); if ($this->hasModel()) { if ($this->form) { echo $this->form->textField($this->model, $this->attribute, $this->htmlOptions); } else { echo CHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions); } } else { echo CHtml::textField($name, $this->value, $this->htmlOptions); } if (!isset($this->options['format'])) { $this->options['format'] = 'yyyy-MM-dd'; } if (!isset($this->options['locale']['applyLabel'])) { $this->options['locale']['applyLabel'] = '应用'; } if (!isset($this->options['locale']['clearLabel'])) { $this->options['locale']['clearLabel'] = '清空'; } if (!isset($this->options['locale']['fromLabel'])) { $this->options['locale']['fromLabel'] = '从'; } if (!isset($this->options['locale']['toLabel'])) { $this->options['locale']['toLabel'] = '至'; } $this->setLocaleSettings(); Yii::app()->bootstrap->registerDateRangePlugin('#' . $id, $this->options, $this->callback); } }
/** * 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()) { echo CHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions); } else { echo CHtml::textField($name, $this->value, $this->htmlOptions); } $options = CJavaScript::encode($this->options); $js = "jQuery('#{$id}').datepicker({$options});"; if (isset($this->language)) { $this->registerScriptFile($this->i18nScriptFile); $js .= "\njQuery('#{$id}').datepicker('option', jQuery.datepicker.regional['{$this->language}']);"; } Yii::app()->getClientScript()->registerScript(__CLASS__ . '#' . $id, $js); }
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(); }
/** * Run this widget. * This method registers necessary CSS and JS files and renders the needed JS and 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->hasModel()) { echo CHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions); } else { echo CHtml::textField($name, $this->value, $this->htmlOptions); } $options = CJavaScript::encode($this->options); $js = "jQuery('#{$id}').tagit({$options});"; $assets = CHtml::asset(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets'); $cs = Yii::app()->getClientScript(); $cs->registerCssFile($assets . '/jquery.tagit.css'); $cs->registerScriptFile($assets . '/tag-it.js', CClientScript::POS_END); // Position is important here! $cs->registerScript(__CLASS__ . '#' . $id, $js); }
public function renderHeader() { echo CHtml::openTag('header', array('id' => 'header')); echo CHtml::openTag('div', array('class' => 'navbar navbar-fixed-top')); echo CHtml::openTag('div', array('class' => 'navbar-inner')); echo CHtml::openTag('a', array('class' => 'brand', 'style' => 'font-size:14px;margin-top:5px;margin-bottom:0px;padding-top:0px;padding-bottom:0px;')); echo $this->model->getAttributeLabel('title'); echo CHtml::textField('title', $this->model->title, array('style' => 'margin-left:36px;margin-bottom:0px;')); echo CHtml::closeTag('a'); echo CHtml::openTag('a', array('class' => 'brand', 'style' => 'font-size:14px;margin-top:5px;margin-bottom:0px;padding-top:0px;padding-bottom:0px;')); echo $this->model->getAttributeLabel('main_id') . ' '; $this->widget('core.widgets.TTreeDropdown', array('treeId' => 'main_id', 'data' => HelpCategory::getHelpTree(), 'options' => array('view' => array('showLine' => false, 'showIcon' => true)), 'defaultText' => $this->model->main->name ? $this->model->main->name : '未分类', 'selectNode' => $this->model->main_id ? $this->model->main_id : '')); echo CHtml::closeTag('a'); //置顶 echo CHtml::openTag('a', array('class' => 'brand', 'style' => 'font-size:14px;margin-top:5px;margin-right:0px;margin-bottom:0px;padding-top:0px;padding-bottom:0px;')); echo CHtml::checkBox('top', $checked = $this->model->top ? true : false, array('style' => 'margin-left:36px;margin-bottom:0px;margin-right:0px')); echo CHtml::closeTag('a'); echo CHtml::openTag('a', array('class' => 'brand', 'style' => 'font-size:14px;margin-top:8px;margin-left:0px;margin-bottom:0px;padding-top:0px;padding-bottom:0px;')); echo $this->model->getAttributeLabel('top'); echo CHtml::closeTag('a'); $this->controller->widget('bootstrap.widgets.TbButton', array('label' => '关闭', 'type' => 'primary', 'htmlOptions' => array('class' => 'pull-right', 'style' => 'margin-left:6px;', 'id' => 'btnCancel'))); $this->controller->widget('bootstrap.widgets.TbButton', array('label' => '保存', 'type' => 'danger', 'htmlOptions' => array('style' => 'margin-left:6px;', 'class' => 'pull-right', 'id' => 'btnSave'))); $this->controller->widget('bootstrap.widgets.TbButton', array('label' => '预览', 'htmlOptions' => array('class' => 'pull-right', 'id' => 'btnPrev'))); echo CHtml::closeTag('div'); echo CHtml::closeTag('div'); echo CHtml::closeTag('header'); }
function renderVariation($variation, $i) { if (!ProductSpecification::model()->findByPk(1)) { return false; } if (!$variation) { $variation = new ProductVariation(); $variation->specification_id = 1; } $str = '<tr> <td>'; $str .= CHtml::dropDownList("Variations[{$i}][specification_id]", $variation->specification_id, CHtml::listData(ProductSpecification::model()->findall(), "id", "title"), array('empty' => '-')); $str .= '</td> <td>'; $str .= CHtml::textField("Variations[{$i}][title]", $variation->title); $str .= '</td> <td>'; // Price adjustion $str .= CHtml::dropDownList("Variations[{$i}][sign_price]", $variation->price_adjustion >= 0 ? '+' : '-', array('+' => '+', '-' => '-')); $str .= '</td> <td>'; $str .= CHtml::textField("Variations[{$i}][price_adjustion]", abs($variation->price_adjustion), array('size' => 5)); // Weight adjustion $str .= '</td> <td>'; $str .= CHtml::dropDownList("Variations[{$i}][sign_weight]", $variation->weight_adjustion >= 0 ? '+' : '-', array('+' => '+', '-' => '-')); $str .= '</td> <td>'; $str .= CHtml::textField("Variations[{$i}][weight_adjustion]", abs($variation->weight_adjustion), array('size' => 5)); $str .= '</td> <td>'; for ($j = -10; $j <= 10; $j++) { $positions[$j] = $j; } $str .= CHtml::dropDownList("Variations[{$i}][position]", $variation->position, $positions); $str .= '</td></tr>'; return $str; }
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()) { echo CHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions); } else { echo CHtml::textField($this->name, $this->value, $this->htmlOptions); } if (isset($this->htmlOptions['id'])) { $id = $this->htmlOptions['id']; } else { $this->htmlOptions['id'] = $id; } $options = CJavaScript::encode($this->options); $cs = Yii::app()->getClientScript(); $assetUrl = Yii::app()->assetManager->publish(Yii::getPathOfAlias('ext.YiiDateTimePicker.assets')); Yii::app()->clientScript->registerScriptFile($assetUrl . '/jquery.datetimepicker.js'); Yii::app()->clientScript->registerCssFile($assetUrl . '/jquery.datetimepicker.css'); $js = "\$('#{$id}').datetimepicker({$options});"; $cs->registerScript(__CLASS__ . '#' . $id, $js); }
/** * 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); echo CHtml::openTag('div', $this->htmlOptions); echo CHtml::openTag('div', array('class' => 'input-prepend bfh-timepicker-toggle', 'data-toggle' => 'bfh-timepicker')); echo CHtml::tag('span', array('class' => 'add-on'), TbHtml::icon(TbHtml::ICON_TIME)); if ($this->hasModel()) { echo CHtml::activeTextField($this->model, $this->attribute, $this->inputOptions); } else { echo CHtml::textField($name, $this->value, $this->inputOptions); } echo CHtml::closeTag('div'); echo '<div class="bfh-timepicker-popover"> <table class="table"> <tbody> <tr> <td class="hour"> <a class="next" href="#"><i class="icon-chevron-up"></i></a><br> <input type="text" class="input-mini" readonly><br> <a class="previous" href="#"><i class="icon-chevron-down"></i></a> </td> <td class="separator">:</td> <td class="minute"> <a class="next" href="#"><i class="icon-chevron-up"></i></a><br> <input type="text" class="input-mini" readonly><br> <a class="previous" href="#"><i class="icon-chevron-down"></i></a> </td> </tr> </tbody> </table> </div>'; echo CHtml::closeTag('div'); }
public function formInput(&$controller, $tagOptions=array()) { ob_start(); $inputName = $this->formInputName(); $inputID = "i_{$inputName}"; echo CHtml::label($this->label, $inputID); echo CHtml::tag('br'); if($this->isReadonly) $tagOptions['disabled'] = true; if($this->value) { $oldOptions = array('readonly'=>true); if($this->isReadonly) $tagOptions['disabled'] = true; echo CHtml::textField("{$inputName}[old]", $this->value, $oldOptions); unset($oldOptions['readonly']); ?> <label class="delfile"> <?php echo Yii::t('AutoAdmin.form', '<b class="warning">Delete</b> the file')?> <span class="tip">(<?php echo Yii::t('AutoAdmin.form', 'set checkbox on for confirm')?>)</span>: <?php echo CHtml::checkBox("{$inputName}[del]", false, $oldOptions);?> </label> <?php } $tagOptions['id'] = $inputID; echo CHtml::label(Yii::t('AutoAdmin.form', 'New file').':', $inputID); ?> <div class="tip inline"><a href=<?php echo $this->options['directoryPath']?>/</div> <?php echo CHtml::fileField(AutoAdmin::INPUT_PREFIX."[{$this->name}_new]", null, $tagOptions); return ob_get_clean(); }
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 (isset($this->settings['ajax'])) { if (isset($this->model)) { echo CHtml::textField($name, $this->model->{$this->attribute}, $this->htmlOptions); } else { echo CHtml::textField($name, $this->value, $this->htmlOptions); } } else { if (isset($this->model)) { echo CHtml::dropDownList($name, $this->model->{$this->attribute}, $this->data, $this->htmlOptions); } else { echo CHtml::dropDownList($name, $this->value, $this->data, $this->htmlOptions); } } $this->registerScripts($id); }
/** * 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()) { echo CHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions); } else { echo CHtml::textField($name, $this->value, $this->htmlOptions); } $options = CJavaScript::encode($this->options); $js = "jQuery('#{$id}').daterangepicker({$options});"; $cs = Yii::app()->getClientScript(); if ($this->language != '' && $this->language != 'en') { $this->registerScriptFile($this->i18nScriptFile); $js .= "setTimeout(function(){jQuery('.range-start, .range-end').datepicker('option', jQuery.datepicker.regional['{$this->language}']);},500);"; } $cs->registerScript(__CLASS__ . '#' . $id, $js, CClientScript::POS_READY); }
/** * @param $attribute * @param null $value * @param null $name * @param array $htmlOptions * @return mixed|null|string */ public static function renderField($attribute, $value = null, $name = null, $htmlOptions = []) { $name = $name ?: 'Attribute[' . $attribute->id . ']'; switch ($attribute->type) { case Attribute::TYPE_SHORT_TEXT: return CHtml::textField($name, $value, $htmlOptions); break; case Attribute::TYPE_TEXT: return Yii::app()->getController()->widget(Yii::app()->getModule('store')->getVisualEditor(), ['name' => $name, 'value' => $value], true); break; case Attribute::TYPE_DROPDOWN: $data = CHtml::listData($attribute->options, 'id', 'value'); return CHtml::dropDownList($name, $value, $data, array_merge($htmlOptions, ['empty' => '---'])); break; case Attribute::TYPE_CHECKBOX_LIST: $data = CHtml::listData($attribute->options, 'id', 'value'); return CHtml::checkBoxList($name . '[]', $value, $data, $htmlOptions); break; case Attribute::TYPE_CHECKBOX: return CHtml::checkBox($name, $value, CMap::mergeArray(['uncheckValue' => 0], $htmlOptions)); break; case Attribute::TYPE_NUMBER: return CHtml::numberField($name, $value, $htmlOptions); break; case Attribute::TYPE_FILE: return CHtml::fileField($name . '[name]', null, $htmlOptions); break; } return null; }
/** * Runs the widget. */ public function run() { // print_r($this->htmlOptions); //typeahead 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->hasModel()) { echo CHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions); } else { echo CHtml::textField($name, $this->value, $this->htmlOptions); } $this->datasets['source'] = 'js:substringMatcher(_' . $this->id . '_source_list)'; $options = CJavaScript::encode($this->options); $datasets = CJavaScript::encode($this->datasets); $eventsScript = array(); foreach ($this->events as $event => $expression) { $eventsScript[] = ".on('typeahead:{$event}',{$expression})"; } $eventsScript = implode("\n", $eventsScript); Yii::app()->clientScript->registerScript(__CLASS__ . '#' . $id, "jQuery('#{$id}').typeahead({$options}, {$datasets})\n{$eventsScript};"); }
/** * ### .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>'; }
/** * 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->hasModel()) { echo CHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions); } else { echo CHtml::textField($name, $this->value, $this->htmlOptions); } if ($this->sourceUrl !== null) { $this->options['source'] = CHtml::normalizeUrl($this->sourceUrl); } else { $this->options['source'] = $this->source; } $options = CJavaScript::encode($this->options); $js = "jQuery('#{$id}').autocomplete({$options}){$this->methodChain};"; $cs = Yii::app()->getClientScript(); $cs->registerScript(__CLASS__ . '#' . $id, $js); }
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()) { echo CHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions); } else { echo CHtml::textField($name, $this->value, $this->htmlOptions); } $options = CJavaScript::encode($this->options); $js = "jQuery('#{$id}').{$this->mode}picker({$options});"; if (isset($this->language)) { $this->registerScriptFile($this->i18nScriptFile); $js = "jQuery('#{$id}').{$this->mode}picker(jQuery.extend({showMonthAfterYear:false}, jQuery.datepicker.regional['{$this->language}'], {$options}));"; } $cs = Yii::app()->getClientScript(); $assets = Yii::app()->getAssetManager()->publish(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets'); $cs->registerCssFile($assets . self::ASSETS_NAME . '.css'); $cs->registerScriptFile($assets . self::ASSETS_NAME . '.js', CClientScript::POS_END); $cs->registerScript(__CLASS__, $this->defaultOptions ? 'jQuery.{$this->mode}picker.setDefaults(' . CJavaScript::encode($this->defaultOptions) . ');' : ''); $cs->registerScript(__CLASS__ . '#' . $id, $js); }
/** * Prints input and register assigned scripts on it * * @throws \CException */ 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 (isset($this->htmlOptions['name'])) { $name = $this->htmlOptions['name']; } else { $this->htmlOptions['name'] = $name; } if ($this->hasModel()) { echo \CHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions); } else { echo \CHtml::textField($name, $this->value, $this->htmlOptions); } $options = \CJavaScript::encode($this->options); $js = "jQuery('#{$id}').datetimepicker({$options});"; \Yii::app()->getClientScript()->registerScript(__CLASS__ . '#' . $id, $js); }
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); }
function run() { if ($this->hasModel()) { echo CHtml::activeTextField($this->model, $this->htmlOptions); } else { echo CHtml::textField($this->name, $this->value, $this->htmlOptions); } }
/** * Renders the widget. */ public function run() { if ($this->hidden) { echo CHtml::hiddenField($this->getId(), $this->defaultValue, $this->htmlOptions); } else { echo CHtml::textField($this->getId(), $this->defaultValue, $this->htmlOptions); } }
/** * Renders field */ public function renderField() { if ($this->hasModel()) { echo \CHtml::activeTextField($this->model, $this->attribute, $this->options); } else { echo \CHtml::textField($this->options['name'], $this->value, $this->options); } }
function groupForm($role) { ob_start(); ?> <table class="stdtable"> <tr> <td> <?php echo CHtml::label(Yii::t('mc', 'Prefix'), 'prefix_' . $role); ?> </td> <td> <?php echo CHtml::label(Yii::t('mc', 'Suffix'), 'suffix_' . $role); ?> </td> <td> <?php echo CHtml::label(Yii::t('mc', 'Can Build'), 'build_' . $role); ?> </td> </tr> <tr> <td> <?php echo CHtml::textField('prefix_' . $role, @$_POST['prefix_' . $role]); ?> </td> <td> <?php echo CHtml::textField('suffix_' . $role, @$_POST['suffix_' . $role]); ?> </td> <td> <?php echo CHtml::dropDownList('build_' . $role, @$_POST['build_' . $role], array(0 => Yii::t('mc', 'Yes'), 1 => Yii::t('mc', 'No'))); ?> </td> </tr> <tr> <td colspan="3"> <?php echo CHtml::label(Yii::t('mc', 'Permissions, comma sepparated'), 'perms_' . $role); ?> </td> </tr> <tr> <td colspan="3"> <?php echo CHtml::textField('perms_' . $role, @$_POST['perms_' . $role], array('style' => 'width: 540px')); ?> </td> </tr> </table> <?php return ob_get_clean(); }
public static function activeText($ngModelName, $ngFieldName, $properties = array()) { $html = ""; if (array_key_exists("html", $properties)) { $html = $properties["html"]; } $html .= ' ng-model="' . $ngModelName . '.' . $ngFieldName . '"'; CHtml::textField($ngModelName . "_" . $ngFieldName, null, "", "", $html); }
/** * Renders the TypeAhead field. If [[model]] has been specified then it will render an active field. * If [[model]] is null or not from an [[Model]] instance, then the field will be rendered according to * the [[name]] attribute. * @return string the rendering result * @throws \CException when none of the required attributes are set to render the textInput. * That is, if [[model]] and [[attribute]] are not set, then [[name]] is required. */ public function renderField() { if ($this->model instanceof \CModel && $this->attribute !== null) { return \CHtml::activeTextField($this->model, $this->attribute, $this->options); } elseif ($this->name !== null) { return \CHtml::textField($this->name, $this->value, $this->options); } else { throw new \CException("Either 'name' or 'model' and 'attribute' properties must be specified."); } }
public function run() { $placeholder = $this->type ? Yii::t('app', 'Search') . ' ' . ucfirst($this->type) . '...' : Yii::t('app', 'Search') . '...'; echo CHtml::beginForm(array('/search/' . $this->type), 'get', array('class' => 'search-form')); echo CHtml::textField('q', $this->query, array('placeholder' => $placeholder)); if ($this->query != '') { echo CHtml::submitButton('Search!', array('name' => '')); } echo CHtml::endForm(''); }
public function run() { // here render procedures echo CHtml::beginForm($this->action, $this->method, array('id' => $this->id, 'enctype' => $this->enctype, 'target' => $this->target)); // you better create a function but // for the sake of the example... foreach ($this->attributes as $attr) { // here we can actually say i // this is very simple but you get the idea echo CHtml::label($attr['label'], $attr['name']); if ($attr['type'] == 'text') { echo CHtml::textField($this->model_name . '[' . $this->category . ']' . '[' . $attr['name'] . ']', $attr['value'], $attr['htmlOptions']); } else { if ($attr['type'] == 'textarea') { echo CHtml::textArea($this->model_name . '[' . $this->category . ']' . '[' . $attr['name'] . ']', $attr['value'], $attr['htmlOptions']); } else { if ($attr['type'] == 'password') { echo CHtml::passwordField($this->model_name . '[' . $this->category . ']' . '[' . $attr['name'] . ']', $attr['value'], $attr['htmlOptions']); } else { if ($attr['type'] == 'checkbox') { echo CHtml::checkBox($this->model_name . '[' . $this->category . ']' . '[' . $attr['name'] . ']', $attr['items'], $attr['htmlOptions']); } else { if ($attr['type'] == 'checkboxlist') { echo CHtml::checkBoxList($this->model_name . '[' . $this->category . ']' . '[' . $attr['name'] . ']', $attr['value'], $attr['items'], $attr['htmlOptions']); } else { if ($attr['type'] == 'date') { echo CHtml::dateField($this->model_name . '[' . $this->category . ']' . '[' . $attr['name'] . ']', $attr['value'], $attr['htmlOptions']); } else { if ($attr['type'] == 'dropdownlist') { echo CHtml::dropDownList($this->model_name . '[' . $this->category . ']' . '[' . $attr['name'] . ']', $attr['value'], $attr['items'], $attr['htmlOptions']); } else { if ($attr['type'] == 'file') { echo CHtml::fileField($this->model_name . '[' . $this->category . ']' . '[' . $attr['name'] . ']', $attr['value'], $attr['items'], $attr['htmlOptions']); } else { if ($attr['type'] == 'hidden') { echo CHtml::hiddenField($this->model_name . '[' . $this->category . ']' . '[' . $attr['name'] . ']', $attr['value'], $attr['items'], $attr['htmlOptions']); } else { if ($attr['type'] == 'radio') { echo CHtml::radioButton($this->model_name . '[' . $this->category . ']' . '[' . $attr['name'] . ']', $attr['items'], $attr['htmlOptions']); } else { if ($attr['type'] == 'radiolist') { echo CHtml::radioButtonList($this->model_name . '[' . $this->category . ']' . '[' . $attr['name'] . ']', $attr['value'], $attr['items'], $attr['htmlOptions']); } } } } } } } } } } } // do more here } echo "<br/><br/><div class='row-fluid'>"; echo CHtml::submitButton($this->submit['label'], $this->submit['options']); echo "</div>"; echo CHtml::endForm(); }