public function run() { if (is_null($this->id)) { if ($this->model instanceof Model) { $this->id = Html::getInputId($this->model, $this->attribute); } else { $this->id = $this->getId(); } } if (is_null($this->name)) { if ($this->model instanceof Model) { $this->name = Html::getInputName($this->model, $this->attribute); } else { $this->name = $this->getId(); } } $this->options['id'] = $this->id; $this->options['name'] = $this->name; switch ($this->type) { case 'checkbox': if ($this->model instanceof Model) { $this->options['label'] = null; echo Html::activeCheckbox($this->model, $this->attribute, $this->options); } else { echo Html::checkbox($this->name, $this->checked, $this->options); } break; case 'radio': if ($this->model instanceof Model) { $this->options['label'] = null; echo Html::activeRadio($this->model, $this->attribute, $this->options); } else { echo Html::radio($this->name, $this->checked, $this->options); } break; default: throw new Exception('Invalid element type'); } $this->register(); }
/** * @inheritdoc */ protected function renderDataCellContent($model, $key, $index) { $items = ''; foreach ($this->buttons as $value => $label) { $items .= Html::label(Html::radio(null, $model->{$this->attribute} == $value, ['value' => $value]) . $label, $model->{$this->attribute} == $value, ['class' => 'btn ' . ($model->{$this->attribute} == $value ? 'btn-primary' : 'btn-default')]); } return Html::tag('div', $items, ['data-action' => 'toggle-column', 'data-attribute' => $this->attribute, 'data-id' => $model->id, 'data-model' => get_class($model), 'data-url' => Url::to($this->updateAction), 'data-toggle' => 'buttons', 'class' => 'btn-group-xs btn-group']); }
/** * Print radio group in boostrap style * */ public function radioListBosstrap($items, $options = []) { $mOptions = array_merge($options, ['class' => 'btn-group', 'data-toggle' => 'buttons', 'unselect' => null, 'item' => function ($index, $label, $name, $checked, $value) { return '<label class="btn btn-default' . ($checked ? ' active' : '') . '">' . Html::radio($name, $checked, ['value' => $value, 'class' => 'project-status-btn']) . $label . '</label>'; }]); return $this->radioList($items, $mOptions); }
/** * @inheritdoc */ protected function renderDataCellContent($model, $key, $index) { if ($this->gridType == 'datatable-select') { if (!$this->multiple) { return Html::radio(rtrim($this->name, '[]'), false, ['value' => $key]); } else { return Html::checkBox($this->name, false, ['value' => $key]); } } else { return parent::renderDataCellContent($model, $key, $index); } }
protected function image($image, $name) { echo Html::beginTag('div', ['class' => 'images-upload-item']); echo Html::beginTag('div', ['class' => 'images-upload-item-content']); echo Html::a(Html::img($image->getUrl('180x180')), $image->getUrl(), ['target' => '_blank']); $checkbox = Html::checkbox($name . '[delete][' . $image->id . ']', false, ['label' => __('Delete')]); echo Html::tag('div', $checkbox, ['class' => 'checkbox']); if (!$image->default) { $radio = Html::radio($name . '[default]', false, ['value' => $image->id, 'label' => __('Set default')]); echo Html::tag('div', $radio, ['class' => 'radio']); } echo Html::endTag('div'); echo Html::endTag('div'); }
private function renderRadioInput() { $items = []; foreach ($this->items as $key => $item) { if (!is_array($item)) { $options = $this->options; $options['value'] = $key; $options['label'] = $item; $options['labelOptions'] = $this->labelOptions; } else { $options = ArrayHelper::getValue($item, 'options', []) + $this->options; $options['value'] = ArrayHelper::getValue($item, 'value'); $options['label'] = ArrayHelper::getValue($item, 'label', false); $options['labelOptions'] = ArrayHelper::getValue($item, 'labelOptions', []) + $this->labelOptions; } if ($this->inline) { $options['container'] = ''; } $items[] = $this->hasModel() ? Html::activeRadio($this->model, $this->attribute, $options) : Html::radio($this->name, $this->checked, $options); } $this->containerOptions['class'] = ArrayHelper::getValue($this->containerOptions, 'class', 'form-group'); print Html::tag('div', implode($this->separator, $items), $this->containerOptions); }
/** * Runs the widget. */ public function run() { if ($this->hasModel()) { $value = Html::getAttributeValue($this->model, $this->attribute); $name = Html::getInputName($this->model, $this->attribute); } else { $value = $this->value; $name = $this->attribute; } $toogle = 'radiotab-' . Inflector::slug($name); $content = $this->inline ? '' : '<div class="clearfix"></div>'; $content .= '<div id="' . $toogle . '" class="btn-group" data-toggle="buttons">'; if (is_array($this->items)) { foreach ($this->items as $id => $label) { $checked = $value == $id ? true : false; $options = ['class' => 'btn btn-default' . ($checked ? ' active' : ''), 'data-toggle' => $toogle]; $radio = Html::radio($name, $checked, ['class' => 'non-styler', 'value' => $id]); $content .= Html::a($radio . $label, null, $options); } } $content .= '</div>'; return $content; }
private function genField($name, $setting, $options) { if (preg_match("/number|string/i", $setting->type)) { return Html::textInput($name, $setting->value, $options); } elseif (preg_match("/text/i", $setting->type)) { return Html::textArea($name, $setting->value, $options); } elseif (preg_match("/bool/i", $setting->type)) { return Html::checkBox($name, $setting->value, array_merge($options, $this->checkboxOptions, ['template' => ''])); } elseif (preg_match("/dropdown/i", $setting->type)) { $data = @unserialize($setting->options); $data = is_array($data) ? $data : []; return Html::dropDownList($name, $setting->value, $data, $options); } elseif (preg_match("/radiolist/i", $setting->type)) { $data = @unserialize($setting->options); $data = is_array($data) ? $data : []; $template = $this->radioTemplate; $this->radioOptions['item'] = !$this->radioCallback ? function ($index, $label, $name, $checked, $value) use($template) { return strtr($template, ['{input}' => Html::radio($name, $checked, ['value' => $value]), '{labelText}' => $label]); } : $this->radioCallback; return Html::radioList($name, $setting->value, $data, array_merge($options, $this->radioOptions)); } elseif (preg_match("/{dateradiolist}/i", $setting->type)) { $data = @unserialize($setting->options); $data = is_array($data) ? $data : []; $template = $this->radioTemplate; $this->radioOptions['item'] = function ($index, $label, $name, $checked, $value) use($template) { return strtr($template, ['{input}' => Html::radio($name, $checked, ['value' => $value]), '{labelText}' => date($value, time())]); }; return Html::radioList($name, $setting->value, array_combine($data, $data), array_merge($options, $this->radioOptions)); } elseif (preg_match("/timezone/i", $setting->type)) { return Html::dropDownList($name, $setting->value, $this->getTimezones(), $options); } elseif (preg_match("/date/i", $setting->type)) { return DatePicker::widget(['name' => $name, 'type' => DatePicker::TYPE_INPUT, 'value' => date('d-m-Y', strtotime($setting->value)), 'pluginOptions' => ['autoclose' => true, 'format' => 'dd-M-yyyy']]); } else { return Html::textArea($name, $setting->value, $options); } }
/** * @inheritdoc */ public function radio($options = [], $enclosedByLabel = true) { $options = $this->mergeInputOptions($options, ['data-bind' => 'checked:' . $this->attribute, 'placeholder' => null]); if ($enclosedByLabel) { $this->parts['{input}'] = Html::radio($this->attribute, null, $options); $this->parts['{label}'] = ''; } else { if (isset($options['label']) && !isset($this->parts['{label}'])) { $this->parts['{label}'] = $options['label']; if (!empty($options['labelOptions'])) { $this->labelOptions = $options['labelOptions']; } } unset($options['label'], $options['labelOptions']); $this->parts['{input}'] = Html::radio($this->attribute, null, $options); } return $this; }
//$disabled = true; // replace with whatever check you use for each item //$checked = false; //if($value == 0){ // $checked = true; //} return Html::radio($name, $checked, ['value' => $value, 'label' => Html::encode($label)]); }]); } if (Yii::$app->user->can("hrm") && $model->reasonApplication->type_id == -11 || Yii::$app->user->can('admin')) { echo $form->field($model, 'hrm_ok')->radioList(array(1 => 'Accept ', 0 => ' Refuse'), ['item' => function ($index, $label, $name, $checked, $value) { //$disabled = true; // replace with whatever check you use for each item //$checked = false; //if($value == 0){ // $checked = true; //} return Html::radio($name, $checked, ['value' => $value, 'label' => Html::encode($label)]); }]); } ?> <div class="form-group"> <?php echo Html::submitButton('Save', ['class' => 'btn btn-primary']); ?> </div> </div> </div> <?php ActiveForm::end(); ?> </div>
<div class="col-lg-offset-1 col-lg-11"> <?php echo Html::input("text", "sec_answer", "autocom", ["required" => "required"]); ?> </div> </div> <label>User type will be attached</label> <div class="form-group"> <div class="col-lg-offset-1 col-lg-11"> <ul> <?php foreach (UserType::find()->asArray()->all() as $key => $value) { echo "<li>"; echo Html::radio("user_type", false, ["label" => $value["name"], "value" => $value["id"]]); echo "</li>"; } ?> </ul> </div> </div> <div class="form-group"> <div class="col-lg-offset-1 col-lg-11"> <?php echo Html::submitButton('Save', ['class' => 'btn btn-primary']); ?> </div> </div>
/** * * render a radio button in Grid View * @param mixed $model * @param mixed $key * @param int $index * @return radio button */ protected function renderDataCellContent($model, $key, $index) { return Html::radio($this->name,false,['value' => $model->primaryKey]); }
/** * Renders the widget. * <div class="custom_label"> * <input type="radio" class="" id="{*some_id*}" > * <label for="{*some_id*}" class="radio_imitation"></label> * <label for="{*some_id*}" class="radio_text">{*text*}</label> * </div> */ public function run() { $this->registerClientScript(); $html = []; if ($this->hasModel()) { $fieldName = $this->attribute; $valueField = $this->model->{$fieldName}; if (!is_null($this->nullString)) { $item = []; if (in_array($valueField, $this->list)) { $id = $this->attrId . '-null'; $item[] = Html::radio($this->attrName, false, ArrayHelper::merge(['id' => $id, 'value' => ''], $this->options['input'])); $item[] = Html::label('', $id, $this->options['label1']); $item[] = Html::label($this->nullString, $id, $this->options['label2']); } else { $id = $this->attrId . '-null'; $item[] = Html::radio($this->attrName, true, ArrayHelper::merge(['id' => $id, 'value' => ''], $this->options['input'])); $item[] = Html::label('', $id, $this->options['label1']); $item[] = Html::label($this->nullString, $id, $this->options['label2']); } $html[] = Html::tag('div', join('', $item), $this->options['div']); } foreach ($this->list as $key => $value) { $item = []; $id = $this->attrId . '-' . $key; if (is_null($valueField)) { $checked = false; } else { $checked = $valueField == $key; } $item[] = Html::radio($this->attrName, $checked, ArrayHelper::merge(['id' => $id, 'value' => $key], $this->options['input'])); $item[] = Html::label('', $id, $this->options['label1']); $item[] = Html::label($value, $id, $this->options['label2']); $html[] = Html::tag('div', join('', $item), $this->options['div']); } } echo join('', $html); }
protected function getApixRadioHtml($form, $config, $field) { $model = $config['model']; $fieldHtml = Html::radio($model . "[{$field->name}]", false, $field->options); if ($config['label']) { $fieldHtml = "<div class='frm-field'><label>{$field->label}</label>{$fieldHtml}<span class='error' cmt-error='{$field->name}'></span></div>"; } else { $fieldHtml = "<div class='frm-field'>{$fieldHtml}<span class='error' cmt-error='{$field->name}'></span></div>"; } return $fieldHtml; }
<?php echo $form->field($model, 'firm_id')->dropDownList(ArrayHelper::map(\app\models\Firm::find()->active()->orderBy('name asc')->all(), 'id', 'name'), ['prompt' => '']); ?> <?php echo $form->field($model, 'workplace_id')->dropDownList(ArrayHelper::map(\app\models\Workplace::find()->active()->all(), 'id', 'name'), ['prompt' => '']); ?> <?php echo $form->field($model, 'note')->textarea(['rows' => 6]); ?> <?php echo $form->field($model, 'rec_status_id')->radioList(ArrayHelper::map(\app\models\RecStatus::find()->active()->all(), 'id', 'name'), ['class' => 'btn-group', 'data-toggle' => 'buttons', 'unselect' => null, 'item' => function ($index, $label, $name, $checked, $value) { return '<label class="btn btn-default' . ($checked ? ' active' : '') . '">' . Html::radio($name, $checked, ['value' => $value, 'class' => 'project-status-btn']) . $label . '</label>'; }]); ?> <?php echo $form->field($model, 'user_id')->dropDownList(ArrayHelper::map(\app\models\User::find()->active()->all(), 'id', 'name'), ['prompt' => '']); ?> <?php echo $form->field($model, 'dc')->textInput(); ?> <div class="form-group"> <div class="col-lg-offset-2 col-lg-10"> <?php echo Html::submitButton($model->isNewRecord ? Yii::t('app', 'Save') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
public function renderNodes($models) { $options["item"] = function ($model) { $isOpen = false; $isActive = false; $controller = \Yii::$app->cms->moduleCms()->createControllerByID("admin-tree"); $controller->setModel($model); $child = ""; foreach ($this->_openedTmp as $activeNode) { if (Validate::validate(new IsSame($activeNode), $model)->isValid()) { $isOpen = true; break; } } if ($isOpen && $model->children) { $child = $this->renderNodes($model->children); } $openCloseLink = ""; $currentLink = ""; if ($model->children) { $openedIds = $this->_getOpenIds(); if ($isOpen) { $newOptionsOpen = []; foreach ($openedIds as $id) { if ($id != $model->id) { $newOptionsOpen[] = $id; } } $urlOptionsOpen = array_unique($newOptionsOpen); $params = \Yii::$app->request->getQueryParams(); $params[$this->openedRequestName] = $urlOptionsOpen; $currentLink = UrlHelper::construct("cms/admin-tree/index")->setData($params); $openCloseLink = Html::a(Html::tag("span", "", ["class" => "glyphicon glyphicon-minus", "title" => \Yii::t('app', "Minimize")]), $currentLink, ['class' => 'btn btn-xs btn-default']); } else { $urlOptionsOpen = array_unique(array_merge($openedIds, [$model->id])); $params = \Yii::$app->request->getQueryParams(); $params[$this->openedRequestName] = $urlOptionsOpen; $currentLink = UrlHelper::construct("cms/admin-tree/index")->setData($params); $openCloseLink = Html::a(Html::tag("span", "", ["class" => "glyphicon glyphicon-plus", "title" => \Yii::t('app', "Restore")]), $currentLink, ['class' => 'btn btn-xs btn-default']); } $openCloseLink = Html::tag("div", $openCloseLink, ["class" => "sx-node-open-close"]); } if ($this->_getMode() == 'multi') { $params = \Yii::$app->request->getQueryParams(); $isSelected = in_array($model->id, $this->_getSelectedIds()) ? true : false; if ($isSelected) { $result = []; foreach ($this->_getSelectedIds() as $id) { if ($id != $model->id) { $result[] = $id; } } $params[$this->selectedRequestName] = $result; } else { $params[$this->selectedRequestName] = array_unique(array_merge($this->_getSelectedIds(), [$model->id])); } $link = UrlHelper::construct("cms/admin-tree/index")->setData($params); $controllElement = Html::checkbox('tree_id', $isSelected, ['value' => $model->id, 'style' => 'float: left; margin-left: 5px; margin-right: 5px;', 'onclick' => new JsExpression(<<<JS sx.Tree.select("{$model->id}", "{$link}"); return false; JS )]); } else { if ($this->_getMode() == 'single') { $params = \Yii::$app->request->getQueryParams(); $isSelected = in_array($model->id, $this->_getSelectedIds()) ? true : false; if ($isSelected) { $params[$this->selectedRequestName] = []; } else { $params[$this->selectedRequestName] = [$model->id]; } $link = UrlHelper::construct("cms/admin-tree/index")->setData($params); $controllElement = Html::radio('tree_id', $isSelected, ['value' => $model->id, 'class' => 'sx-readio', 'style' => 'float: left; margin-left: 5px; margin-right: 5px;', 'onclick' => new JsExpression(<<<JS sx.Tree.selectSingle("{$model->id}"); JS )]); } else { if ($this->_getMode() == 'combo') { $params = \Yii::$app->request->getQueryParams(); $isSelected = in_array($model->id, $this->_getSelectedIds()) ? true : false; if ($isSelected) { $result = []; foreach ($this->_getSelectedIds() as $id) { if ($id != $model->id) { $result[] = $id; } } $params[$this->selectedRequestName] = $result; } else { $params[$this->selectedRequestName] = array_unique(array_merge($this->_getSelectedIds(), [$model->id])); } $link = UrlHelper::construct("cms/admin-tree/index")->setData($params); $controllElement = Html::radio('tree_id', false, ['value' => $model->id, 'class' => 'sx-readio', 'style' => 'float: left; margin-left: 5px; margin-right: 5px;', 'onclick' => new JsExpression(<<<JS sx.Tree.selectSingle("{$model->id}"); JS )]); $controllElement .= Html::checkbox('tree_id', $isSelected, ['value' => $model->id, 'style' => 'float: left; margin-left: 5px; margin-right: 5px;', 'onclick' => new JsExpression(<<<JS sx.Tree.select("{$model->id}", "{$link}"); return false; JS )]); } else { $controllElement = ''; } } } /** * @var $model \skeeks\cms\models\Tree */ $additionalName = ''; if ($model->level == 0) { if ($model->site) { $additionalName = $model->site->name; } } else { if ($model->name_hidden) { $additionalName = $model->name_hidden; } } $link = Html::a('<span class="glyphicon glyphicon-eye-open"></span>', $model->getAbsoluteUrl(), ["target" => "_blank", "class" => "btn-tree-node-controll btn btn-default btn-xs show-at-site", "title" => \Yii::t('app', "Show at site")]); $subsection = \Yii::t('app', 'Create subsection'); return Html::tag("li", Html::tag("div", $openCloseLink . $controllElement . Html::tag("div", Html::a($model->name . ($additionalName ? ' [' . $additionalName . ']' : ''), $currentLink), ["class" => "sx-label-node level-" . $model->level . " status-" . $model->active]) . ($model->treeType ? Html::tag("div", $model->treeType->name, ["class" => "pull-left sx-tree-type"]) : '') . Html::tag("div", DropdownControllerActions::widget(["controller" => $controller, "renderFirstAction" => false, "containerClass" => "dropdown pull-left", 'clientOptions' => ['pjax-id' => 'sx-pjax-tree']]) . Html::tag("div", <<<HTML <a href="#" class="btn-tree-node-controll btn btn-default btn-xs add-tree-child" title="{$subsection}" data-id={$model->id}><span class="glyphicon glyphicon-plus"></span></a> HTML , ["class" => "pull-left sx-controll-act"]) . Html::tag("div", $link, ["class" => "pull-left sx-controll-act"]), ["class" => "sx-controll-node row"]), ["class" => "row"]) . $child, ["class" => "sx-tree-node " . ($isActive ? " active" : "") . ($isOpen ? " open" : ""), "data-id" => $model->id]); }; $ul = Html::ul($models, $options); return $ul; }
/** * @inheritdoc */ public function radioList($items, $options = []) { $this->template = $this->form->layout === 'inline' ? $this->inlineTemplate : $this->radioListTemplate; if (!isset($options['item'])) { $options['item'] = function ($index, $label, $name, $checked, $value) { return Html::radio($name, $checked, ['label' => $label, 'value' => $value]); }; } parent::radioList($items, $options); return $this; }
/** * @inheritdoc */ protected function renderDataCellContent($model, $key, $index) { if ($this->radioOptions instanceof Closure) { $options = call_user_func($this->radioOptions, $model, $key, $index, $this); } else { $options = $this->radioOptions; if (!isset($options['value'])) { $options['value'] = is_array($key) ? Json::encode($key) : $key; } } return Html::radio($this->name, !empty($options['checked']), $options); }
public function testRadioList() { $this->assertEquals('<div></div>', Html::radioList('test')); $expected = <<<EOD <div><div class="radio"><label><input type="radio" name="test" value="value1"> text1</label></div> <div class="radio"><label><input type="radio" name="test" value="value2" checked> text2</label></div></div> EOD; $this->assertEqualsWithoutLE($expected, Html::radioList('test', ['value2'], $this->getDataItems())); $expected = <<<EOD <div><div class="radio"><label><input type="radio" name="test" value="value1<>"> text1<></label></div> <div class="radio"><label><input type="radio" name="test" value="value 2"> text 2</label></div></div> EOD; $this->assertEqualsWithoutLE($expected, Html::radioList('test', ['value2'], $this->getDataItems2())); $expected = <<<EOD <input type="hidden" name="test" value="0"><div><div class="radio"><label><input type="radio" name="test" value="value1"> text1</label></div><br> <div class="radio"><label><input type="radio" name="test" value="value2" checked> text2</label></div></div> EOD; $this->assertEqualsWithoutLE($expected, Html::radioList('test', ['value2'], $this->getDataItems(), ['separator' => "<br>\n", 'unselect' => '0'])); $expected = <<<EOD <div>0<label>text1 <input type="radio" name="test" value="value1"></label> 1<label>text2 <input type="radio" name="test" value="value2" checked></label></div> EOD; $this->assertEqualsWithoutLE($expected, Html::radioList('test', ['value2'], $this->getDataItems(), ['item' => function ($index, $label, $name, $checked, $value) { return $index . Html::label($label . ' ' . Html::radio($name, $checked, ['value' => $value])); }])); }
public function getAsAddon() { $ret_val = ''; $items = []; $itemsLabels = []; $form = $this->form; $attribute = $this->attribute; $this->model->{$attribute} = !$this->model->{$attribute} || !array_key_exists($this->model->{$attribute}, $this->priorities) ? 'normal' : $this->model->{$attribute}; foreach ($this->priorities as $name => $priority) { $text = isset($priority['text']) ? $priority['text'] : ucfirst($name); $priorityOptions = isset($this->_defaultPriorities[$name]) ? $this->_defaultPriorities[$name] : $this->defaultPriorities['normal']; $options = isset($priority['options']) ? array_merge($priorityOptions, $priority['options']) : $priorityOptions; switch ($this->addonType) { case 'buttons': case 'checkboxlist': case 'radiolist': $btnQualifier = 'btn'; break; default: $btnQualifier = 'bg'; break; } $options['class'] = "{$btnQualifier} {$btnQualifier}-" . $options['class']; switch ($this->size) { case 'tiny': $options['class'] .= " {$btnQualifier}-xs"; break; case 'small': $options['class'] .= " {$btnQualifier}-sm"; break; case 'large': $options['class'] .= " {$btnQualifier}-lg"; break; } $options['value'] = $name; $items[$name] = $text; $itemsLabels[$name] = ['label' => $text, 'options' => $options, 'url' => '#']; } $itemsLabels[$this->model->{$attribute}]['options']['class'] .= ' active'; $this->options['inline'] = $this->inputsInline; switch ($this->addonType) { case 'dropdown': $ret_val = \yii\bootstrap\ButtonDropdown::widget(['label' => 'Priority', 'dropdown' => ['items' => $itemsLabels], 'options' => ['class' => 'btn-primary']]); break; case 'radiolist': $this->options['data-toggle'] = 'buttons'; $this->options['class'] = 'btn-group'; $this->options['item'] = function ($index, $label, $name, $checked, $value) use($itemsLabels) { $itemOptions = ['value' => $value]; return Html::label(Html::radio($name, $checked, $itemOptions) . ' ' . $label['label'], null, $itemsLabels[$value]['options']); }; $ret_val = $this->form->field($this->model, $this->attribute)->radioList($itemsLabels, $this->options)->label("Priority", ['class' => 'sr-only']); break; case 'checkboxlist': $this->options['itemOptions'] = ['labelOptions' => ['class' => 'btn']]; $ret_val = $this->form->field($this->model, $this->attribute, ['options' => ['class' => 'btn-group', 'data-toggle' => 'buttons']])->checkBoxList($items, $this->options); break; default: //Return as buttons by default $model = $this->model; $ret_val = implode(PHP_EOL, array_map(function ($item) use($model, $form, $attribute) { //$item['options']['name'] = $model::formName()."[$attribute]"; $item['options']['id'] = strtolower($model::formName() . "-{$attribute}"); return Html::tag('button', $item['label'], $item['options']); }, $itemsLabels)); break; } return $ret_val; }
<?php $form = ActiveForm::begin(['id' => 'notice-form', 'enableAjaxValidation' => true, 'options' => ['enctype' => 'multipart/form-data'], 'fieldConfig' => ['template' => "{label}{input}{error}"]]); ?> <?php echo $form->field($model, 'notice_title')->textInput(['maxlength' => 25, 'placeholder' => 'Enter Title', 'title' => 'Title']); ?> <?php echo $form->field($model, 'notice_description')->textArea(['maxlength' => 255, 'placeholder' => 'Enter Description']); ?> <?php echo $form->field($model, 'notice_user_type')->radioList(["S" => 'Student', "E" => 'Employee', '0' => 'General'], ['item' => function ($index, $label, $name, $checked, $value) { $return = '<label class="left-padding">'; $return .= Html::radio($name, $checked, ['value' => $value]); $return .= '<i></i>'; $return .= '<span> ' . ucwords($label) . '</span>'; $return .= '</label>'; return $return; }])->label('User Type'); ?> <?php echo $form->field($model, 'notice_date')->widget(yii\jui\DatePicker::className(), ['clientOptions' => ['dateFormat' => 'dd-mm-yyyy', 'changeMonth' => true, 'changeYear' => true, 'autoSize' => true], 'options' => ['class' => 'form-control', 'placeholder' => 'Select Date']]); ?> <?php echo $form->field($model, 'notice_file_path')->fileInput(); ?>
/** * @inheritdoc */ public function radioList($items, $options = []) { if ($this->inline) { if (!isset($options['template'])) { $this->template = $this->inlineRadioListTemplate; } else { $this->template = $options['template']; unset($options['template']); } if (!isset($options['itemOptions'])) { $options['itemOptions'] = ['labelOptions' => ['class' => 'radio-inline']]; } } elseif (!isset($options['item'])) { $options['item'] = function ($index, $label, $name, $checked, $value) { return '<div class="radio">' . Html::radio($name, $checked, ['label' => $label, 'value' => $value]) . '</div>'; }; } parent::radioList($items, $options); return $this; }
?> <?php echo Html::activeHiddenInput($node, $iconTypeAttribute); ?> <?php echo $form->field($node, $nameAttribute)->textArea(['rows' => 3] + $inputOpts); ?> </div> <div class="col-sm-6"> <?php echo $form->field($node, $iconAttribute)->multiselect($iconsList, ['item' => function ($index, $label, $name, $checked, $value) use($inputOpts) { if ($index == 0 && $value == '') { $checked = true; $value = ''; } return '<div class="radio">' . Html::radio($name, $checked, ['value' => $value, 'label' => $label, 'disabled' => !empty($inputOpts['readonly']) || !empty($inputOpts['disabled'])]) . '</div>'; }, 'selector' => 'radio']); ?> </div> </div> <?php } ?> <?php /** * SECTION 7: Additional views part 2 - before admin zone. */ echo $renderContent(Module::VIEW_PART_2); ?>
?> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span> </button> <h4 class="modal-title" id="myModalLabel">Include update</h4> </div> <?php $form = ActiveForm::Begin(['method' => 'post']); ?> <div class="modal-body"> <ul> <?php echo $form->field($model, 'included')->label('Please change:')->radioList(Dict::$monitoringExceptionalSecurityInclude, ['item' => function ($index, $label, $name, $checked, $value) { $radio = Html::radio($name, $checked, ['value' => $value]); $label = Html::label($radio . $label); return Html::tag('div', $label, ['class' => 'radio col-xs-6']); }]); ?> </ul> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button> <?php echo Html::submitButton('Save', ['class' => 'btn btn-primary']); ?> </div> <?php ActiveForm::end(); ?>
<h3 >添加子节点</h3> <?php $form = \yii\bootstrap\ActiveForm::begin([]); ?> <?php echo $form->field($model, 'parent')->textInput(['value' => $name, 'readonly' => 'readonly']); ?> <?php echo $form->field($model, 'child')->textInput(['placeholder' => '请输入子节点name']); ?> <?php echo Html::activeRadioList($model, 'childType', [1 => '角色', 2 => '许可'], ['item' => function ($index, $label, $name, $checked, $value) { if ($value == 1) { $checked = true; } return '<label class="radio-inline">' . Html::radio($name, $checked, ['value' => $value]) . $label . '</label>'; }]); ?> <?php echo Html::submitButton(t('app', 'create'), ['class' => 'btn btn-primary']); ?> <?php $form->end(); ?> </div>
</p> <table class="table table-stripped"> <tbody> <?php foreach ($answers as $answer) { ?> <tr> <td><?php echo $answer->title; ?> </td> <td><?php echo $answer->voteCount; ?> </td> <td><?php echo $model->isNewRecord && $question->isOpen() ? Html::radio('Vote[answer_id]', $model->answer_id == $answer->id, ['value' => $answer->id, 'onchange' => '$(this).parents("form").submit();']) : ($model->answer_id == $answer->id ? '<i class="glyphicon glyphicon-ok"></i>' : ''); ?> </td> </tr> <?php } ?> </tbody> </table> <?php ActiveForm::end(); ?> </div>
<?php /* @var $this ForumController */ /* @var $model YBoardChoice */ use yii\helpers\Html; ?> <div class="row"> <div class="poll col-md-12"> <?php if ($this->context->poll->allow_multiple) { ?> <?php echo Html::checkBox('choice[' . $model->id . ']', false, array('value' => $model->id)); ?> <?php } else { ?> <?php echo Html::radio('choice[]', false, array('value' => $model->id)); ?> <?php } ?> <?php echo $model->choice; ?> </div> </div>
/** * @inheritdoc */ protected function renderDataCellContent($model, $key, $index) { if ($this->radioOptions instanceof Closure) { $options = call_user_func($this->radioOptions, $model, $key, $index, $this); } else { $options = $this->radioOptions; if (!isset($options['value'])) { $options['value'] = is_array($key) ? json_encode($key, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) : $key; } } $checked = isset($options['checked']) ? $options['checked'] : false; return Html::radio($this->name, $checked, $options); }
public function radioList($items, $options = []) { $options['tag'] = 'ul'; $inputId = Html::getInputId($this->model, $this->attribute); $this->selectors = ['input' => "#{$inputId} input"]; $options['class'] = 'da-form-list inline'; $encode = !isset($options['encode']) || $options['encode']; $itemOptions = isset($options['itemOptions']) ? $options['itemOptions'] : []; $options['item'] = function ($index, $label, $name, $checked, $value) use($encode, $itemOptions) { $radio = Html::radio($name, $checked, array_merge($itemOptions, ['value' => $value, 'label' => $encode ? Html::encode($label) : $label])); return '<li>' . $radio . '</li>'; }; return parent::radioList($items, $options); }
public function init() { if (!$this->activeField instanceof ActiveField) { throw new Exception("'activeField' must be set and instance of yii\\widgets\\ActiveField"); } $defaultOptions = ['class' => 'btn-group', 'data-toggle' => 'buttons', 'item' => function ($index, $label, $name, $checked, $value) { return '<label class="btn btn-default' . ($checked ? ' active' : '') . '">' . Html::radio($name, $checked, ['value' => $value, 'class' => '']) . $label . '</label>'; }]; if ($this->options === null) { $this->options = $defaultOptions; } elseif (is_array($this->options)) { $this->options = array_merge($defaultOptions, $this->options); } else { throw new Exception("'options' must be array"); } parent::init(); }