public function actionForm() { echo Html::beginForm(); echo Html::checkboxList('test', ['value 1' => 'item 1', 'value 2' => 'item 2', 'value 3' => 'item 3'], isset($_POST['test']) ? $_POST['test'] : null, function ($index, $label, $name, $value, $checked) { return Html::label($label . ' ' . Html::checkbox($name, $value, $checked), null, ['class' => 'inline checkbox']); }); echo Html::submitButton(); echo Html::endForm(); print_r($_POST); }
/** * */ public function run() { $view = $this->getView(); $this->registerScript($view); if ($this->hasModel()) { if ($this->label) { $label = $this->label; } else { $label = Html::encode($this->model->getAttributeLabel(Html::getAttributeName($this->attribute))); } $tag = ArrayHelper::remove($this->textOptions, 'tag', 'span'); $text = Html::tag($tag, $label, $this->textOptions); $this->options['label'] = $text; $checkbox = Html::activeCheckbox($this->model, $this->attribute, $this->options); } else { $checkbox = Html::checkbox($this->name, $this->value, $this->options); if ($this->label) { $tag = ArrayHelper::remove($this->textOptions, 'tag', 'span'); $text = Html::tag($tag, $this->label, $this->textOptions); $checkbox = Html::tag('label', $checkbox . ' ' . $text, $this->labelOptions); } } $input = Html::tag('div', $checkbox, $this->containerOptions); echo strtr($this->template, ['{input}' => $input]); }
public function run() { if (is_null($this->imageOptions)) { $this->imageOptions = ['class' => 'img-responsive']; } $this->imageOptions['id'] = Yii::$app->getSecurity()->generateRandomString(10); $inputField = Html::getInputId($this->model, $this->attribute); $class = \yii\helpers\StringHelper::basename(get_class($this->model)) . 'Cutter'; echo Html::beginTag('div', ['class' => 'image-cutter', 'id' => $inputField . '-cutter']); echo Html::activeFileInput($this->model, $this->attribute); echo Html::hiddenInput($class . '[' . $this->attribute . ']', $this->model->{$this->attribute}); $previewImage = Html::beginTag('div', ['class' => 'img-container']); $previewImage .= Html::tag('span', '', ['class' => 'helper']); $previewImage .= Html::tag('span', Yii::t('sadovojav/cutter/cutter', 'Click to upload image'), ['class' => 'message']); $previewImage .= Html::img($this->model->{$this->attribute} ? $this->model->{$this->attribute} : null, ['class' => 'preview-image']); $previewImage .= Html::endTag('div'); echo Html::label($previewImage, Html::getInputId($this->model, $this->attribute), ['class' => 'dropzone']); echo Html::checkbox($class . '[' . $this->attribute . '-remove]', false, ['label' => Yii::t('sadovojav/cutter/cutter', 'Remove')]); Modal::begin(['header' => Html::tag('h4', Yii::t('sadovojav/cutter/cutter', 'Cutter'), ['class' => 'modal-title']), 'closeButton' => false, 'footer' => $this->getModalFooter($inputField), 'size' => Modal::SIZE_LARGE]); echo Html::beginTag('div', ['class' => 'image-container']); echo Html::img(null, $this->imageOptions); echo Html::endTag('div'); echo Html::tag('br'); echo Html::beginTag('div', ['class' => 'row']); echo Html::beginTag('div', ['class' => 'col-md-2']); echo Html::label(Yii::t('sadovojav/cutter/cutter', 'Aspect ratio'), $inputField . '-aspectRatio'); echo Html::textInput($class . '[' . $this->attribute . '-aspectRatio]', isset($this->cropperOptions['aspectRatio']) ? $this->cropperOptions['aspectRatio'] : 0, ['id' => $inputField . '-aspectRatio', 'class' => 'form-control']); echo Html::endTag('div'); echo Html::beginTag('div', ['class' => 'col-md-2']); echo Html::label(Yii::t('sadovojav/cutter/cutter', 'Angle'), $inputField . '-dataRotate'); echo Html::textInput($class . '[' . $this->attribute . '-cropping][dataRotate]', '', ['id' => $inputField . '-dataRotate', 'class' => 'form-control']); echo Html::endTag('div'); echo Html::beginTag('div', ['class' => 'col-md-2']); echo Html::label(Yii::t('sadovojav/cutter/cutter', 'Position') . ' (x)', $inputField . '-dataX'); echo Html::textInput($class . '[' . $this->attribute . '-cropping][dataX]', '', ['id' => $inputField . '-dataX', 'class' => 'form-control']); echo Html::endTag('div'); echo Html::beginTag('div', ['class' => 'col-md-2']); echo Html::label(Yii::t('sadovojav/cutter/cutter', 'Position') . ' (y)', $inputField . '-dataY'); echo Html::textInput($class . '[' . $this->attribute . '-cropping][dataY]', '', ['id' => $inputField . '-dataY', 'class' => 'form-control']); echo Html::endTag('div'); echo Html::beginTag('div', ['class' => 'col-md-2']); echo Html::label(Yii::t('sadovojav/cutter/cutter', 'Width'), $inputField . '-dataWidth'); echo Html::textInput($class . '[' . $this->attribute . '-cropping][dataWidth]', '', ['id' => $inputField . '-dataWidth', 'class' => 'form-control']); echo Html::endTag('div'); echo Html::beginTag('div', ['class' => 'col-md-2']); echo Html::label(Yii::t('sadovojav/cutter/cutter', 'Height'), $inputField . '-dataHeight'); echo Html::textInput($class . '[' . $this->attribute . '-cropping][dataHeight]', '', ['id' => $inputField . '-dataHeight', 'class' => 'form-control']); echo Html::endTag('div'); echo Html::endTag('div'); Modal::end(); echo Html::endTag('div'); $options = ['inputField' => $inputField, 'useWindowHeight' => $this->useWindowHeight, 'cropperOptions' => $this->cropperOptions]; $options = Json::encode($options); $this->view->registerJs('jQuery("#' . $inputField . '").cutter(' . $options . ');'); }
protected function get_content($data, $isActiveForm = FALSE) { $res = array(); // Ссылка добавления настройка для секции $res[] = Html::a('<i class="fa fa-cog"></i> add', [$this->add_set_link], ['class' => 'add_settings_in_section']); foreach ($data as $item) { $res[] = '<div class="row">' . '<div class="form-group">' . Html::label($item['key'], $item['key'], ['class' => 'col-sm-2 control-label']) . '<div class="col-sm-3">' . $this->set_input_type($item['type'], $item['key'], $item['value']) . Html::hiddenInput($item['key'] . '[type]', $item['type']) . '</div>' . '</div>' . '<div class="col-sm-4">' . Html::tag('span', $item['description']) . '</div>' . Html::label('active', 'active', ['class' => 'col-sm-2 control-label']) . '<div class="col-sm-1">' . Html::checkbox($item['key'] . '[active]', $this->has_checked($this->has_checked($item['active'])), ['data-atr' => 'icheck', 'class' => 'flat-red']) . '</div>'; } return $res; }
public static function buildHtmlTreeInput($model, $attribute, $data) { $value = $model->{$attribute}; $lines = []; if (is_array($data) && count($data) > 0) { $lines[] = '<ul>'; foreach ($data as $k => $v) { $lines[] = '<li>'; $lines[] = '<div class="checkbox icheck">'; $lines[] = Html::checkbox(Html::getInputName($model, $attribute) . '[' . $k . ']', isset($value[$k]), ['value' => $k, 'label' => '<span>' . (Yii::t('b/radiata/user', $attribute . '_' . $k) != $attribute . '_' . $k ? Yii::t('b/radiata/user', $attribute . '_' . $k) : $k) . '</span>']); $lines[] = '</div>'; if (is_array($v)) { $lines[] = self::buildHtmlTreeInput($model, $attribute, $v); } $lines[] = '</li>'; } $lines[] = '</ul>'; } return join("\n", $lines); }
public function actionIndex() { $dataAry = $columns = []; $auth = Yii::$app->authManager; //只挑選本店家權限 $_cnt = 1; foreach ($auth->getPermissions() as $key => $value) { $_tmp = array('id' => $_cnt, 'label' => $value->description); $_tmp["assign_1"] = Html::checkbox("assign_item", true, ["disabled" => true]); // $_tmp["assign_1"] = Html::checkbox("assign_item", $auth->hasChild($auth->getRole("1"), $value), ["class" => "role-assign", // "data-name" => $value->name, // "data-role" => 1]); $_tmp["assign_2"] = Html::checkbox("assign_item", $auth->hasChild($auth->getRole("2"), $value), ["class" => "role-assign", "data-name" => $value->name, "data-role" => 2]); $_tmp["assign_3"] = Html::checkbox("assign_item", $auth->hasChild($auth->getRole("3"), $value), ["class" => "role-assign", "data-name" => $value->name, "data-role" => 3]); $dataAry[] = $_tmp; $_cnt++; } $dataProvider = new ArrayDataProvider(['allModels' => $dataAry, 'pagination' => false]); $columns[] = array("header" => "功能", 'format' => 'raw', 'options' => ["style" => "width:20%;"], "value" => function ($data) { return $data["label"]; }); foreach (Yii::$app->params["adminRoleType"] as $key => $value) { $columns[] = array("header" => $value, 'format' => 'raw', "value" => function ($data) use($key) { return $data["assign_" . $key]; }); } return $this->render('index', ['dataProvider' => $dataProvider, "columns" => $columns]); }
private function variant($item) { $return = []; $checked = $this->model->checkedId($item->id); $return[] = Html::checkbox('variant', $checked, ['id' => 'filtervariant' . $item->id, 'data-id' => $item->id]); $return[] = ' '; $return[] = Html::label($item->value, 'filtervariant' . $item->id); return Html::tag('li', implode('', $return)); }
private function renderCheckboxInput() { if ($this->hasModel()) { $input = Html::activeCheckbox($this->model, $this->attribute, $this->options); } else { $input = Html::checkbox($this->name, $this->checked, $this->options); } print $this->inlineLabel ? $input : Html::tag('div', $input); }
/** * @inheritdoc */ protected function renderDataCellContent($model, $key, $index) { $this->options['value'] = $model->name; $role = \Yii::$app->request->get('role'); if (in_array($model->name, $this->children[$role])) { return Html::checkbox($this->name, true, $this->options); } else { return Html::checkbox($this->name, false, $this->options); } }
/** * Runs the widget * * @return string */ public function run() { $this->registerAssets(); if ($this->hasModel()) { echo Html::activeCheckbox($this->model, $this->attribute, $this->options); } else { $checked = ArrayHelper::remove($this->options, 'checked', false); echo Html::checkbox($this->name, $checked, $this->options); } }
/** * @inheritdoc */ protected function renderDataCellContent($model, $key, $index) { $this->options['value'] = $model->_id; $this->options['id'] = 'selection_' . uniqid(); if (in_array($model->_id, $this->itemPermissions)) { return null; } else { return Html::checkbox($this->name, false, $this->options); } }
private function variant($item, $checked) { $return = []; if ($checked) { $checked = in_array($item->id, $checked); } $return[] = Html::checkbox('variant', $checked, ['autocomplete' => 'off', 'id' => 'fieldvariant' . $item->id, 'data-id' => $item->id]); $return[] = ' '; $return[] = Html::label($item->value, 'fieldvariant' . $item->id); return Html::tag('li', implode('', $return)); }
public function run() { if (is_null($this->imageOptions)) { $this->imageOptions = ['class' => 'img-responsive']; } $this->imageOptions['id'] = Yii::$app->getSecurity()->generateRandomString(10); $inputField = Html::getInputId($this->model, $this->attribute); echo Html::beginTag('div', ['id' => $inputField . '-cutter']); echo Html::activeFileInput($this->model, $this->attribute, ['class' => 'hide']); echo Html::beginTag('div', ['class' => 'preview-pane', 'style' => $this->model->{$this->attribute} ? 'display:block' : 'display:none']); echo Html::beginTag('div', ['class' => 'preview-container']); echo Html::img($this->previewImgSrc ? $this->previewImgSrc : $this->model->{$this->attribute}, ['class' => 'preview-image ' . $this->previewImgClass]); echo Html::endTag('div'); echo Html::endTag('div'); echo Html::checkbox($this->attribute . '-remove', false, ['label' => Yii::t('davfervaz/cutter', 'Remove photo')]); Modal::begin(['header' => Html::tag('h4', Yii::t('davfervaz/cutter', 'Select the cut area')), 'closeButton' => [], 'footer' => $this->getModalFooter($inputField), 'size' => Modal::SIZE_LARGE]); echo Html::beginTag('div', ['class' => 'image-container']); echo Html::img(null, $this->imageOptions); echo Html::endTag('div'); echo Html::tag('br'); echo Html::beginTag('div', ['class' => 'row']); echo Html::beginTag('div', ['class' => 'col-md-2']); echo Html::label(Yii::t('davfervaz/cutter', 'ASPECT_RATIO'), $inputField . '-aspectRatio'); echo Html::textInput($this->attribute . '-aspectRatio', isset($this->cropperOptions['aspectRatio']) ? $this->cropperOptions['aspectRatio'] : 0, ['id' => $inputField . '-aspectRatio', 'class' => 'form-control']); echo Html::endTag('div'); echo Html::beginTag('div', ['class' => 'col-md-2']); echo Html::label(Yii::t('davfervaz/cutter', 'ANGLE'), $inputField . '-dataRotate'); echo Html::textInput($this->attribute . '-cropping[dataRotate]', '', ['id' => $inputField . '-dataRotate', 'class' => 'form-control']); echo Html::endTag('div'); echo Html::beginTag('div', ['class' => 'col-md-2']); echo Html::label(Yii::t('davfervaz/cutter', 'POSITION') . ' (X)', $inputField . '-dataX'); echo Html::textInput($this->attribute . '-cropping[dataX]', '', ['id' => $inputField . '-dataX', 'class' => 'form-control']); echo Html::endTag('div'); echo Html::beginTag('div', ['class' => 'col-md-2']); echo Html::label(Yii::t('davfervaz/cutter', 'POSITION') . ' (Y)', $inputField . '-dataY'); echo Html::textInput($this->attribute . '-cropping[dataY]', '', ['id' => $inputField . '-dataY', 'class' => 'form-control']); echo Html::endTag('div'); echo Html::beginTag('div', ['class' => 'col-md-2']); echo Html::label(Yii::t('davfervaz/cutter', 'WIDTH'), $inputField . '-dataWidth'); echo Html::textInput($this->attribute . '-cropping[dataWidth]', '', ['id' => $inputField . '-dataWidth', 'class' => 'form-control']); echo Html::endTag('div'); echo Html::beginTag('div', ['class' => 'col-md-2']); echo Html::label(Yii::t('davfervaz/cutter', 'HEIGHT'), $inputField . '-dataHeight'); echo Html::textInput($this->attribute . '-cropping[dataHeight]', '', ['id' => $inputField . '-dataHeight', 'class' => 'form-control']); echo Html::endTag('div'); echo Html::endTag('div'); Modal::end(); echo Html::endTag('div'); $view = $this->getView(); CutterAsset::register($view); $options = ['inputField' => $inputField, 'useWindowHeight' => $this->useWindowHeight, 'cropperOptions' => $this->cropperOptions]; $options = Json::encode($options); $view->registerJs('jQuery("#' . $inputField . '").cutter(' . $options . ');'); }
/** * @inheritdoc */ public function run() { if ($this->hasModel()) { $input = Html::activeCheckbox($this->model, $this->attribute, $this->options); } else { $input = Html::checkbox($this->name, $this->checked, $this->options); } echo $this->inlineLabel ? $input : Html::tag('div', $input); $this->selector = "#{$this->options['id']}"; $this->registerClientScript(); }
/** * @inheritdoc */ public function run() { $option = array_merge(['label' => false, 'class' => 'make-switch'], $this->options); if ($this->hasModel()) { $input = Html::activeCheckbox($this->model, $this->attribute, $option); } else { $input = Html::checkbox($this->name, $this->checked, $option); } echo $this->inlineLabel ? $input : Html::tag('div', $input); $this->selector = "#{$option['id']}"; $this->registerClientScript(); }
/** * @inheritdoc */ protected function renderDataCellContent($model, $key, $index) { if ($this->checkboxOptions instanceof Closure) { $options = call_user_func($this->checkboxOptions, $model, $key, $index, $this); } else { $options = $this->checkboxOptions; if (!isset($options['value'])) { $options['value'] = is_array($key) ? json_encode($key) : $key; } } return Html::checkbox($this->name, !empty($options['checked']), $options); }
protected function renderDataCellContent($model, $key, $index) { if ($this->checkboxOptions instanceof Closure) { $options = call_user_func($this->checkboxOptions, $model, $key, $index, $this); } else { $options = $this->checkboxOptions; if (!isset($options['value'])) { $options['value'] = is_array($key) ? json_encode($key, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) : $key; } } return '<div class="input-control checkbox"><label>' . Html::checkbox($this->name, !empty($options['checked']), $options) . '<span class="check"></span></label></div>'; }
public function run() { $list = []; $selectedValue = $this->model->{$this->attribute}; $_index = 0; foreach ($this->items as $k => $v) { $list[] = Html::tag('li', Html::checkbox($this->name, $k == $selectedValue, ['id' => $this->id . '_' . $_index, 'hidden' => 'hidden']) . Html::label($v, $this->id . '_' . $_index)); $_index++; } $this->options['class'] .= ' m00nk_b3w_checkboxlist'; echo Html::tag('ul', implode('', $list), $this->options); }
/** * @inheritdoc */ protected function renderDataCellContent($model, $key, $index) { if ($this->checkboxOptions instanceof Closure) { $options = call_user_func($this->checkboxOptions, $model, $key, $index, $this); } else { $options = $this->checkboxOptions; if (!isset($options['value'])) { $options['value'] = is_array($key) ? json_encode($key, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) : $key; } $options['id'] = 'selection_' . $key; } return Html::tag('div', Html::checkbox($this->name, !empty($options['checked']), $options) . Html::tag('label', null, ['for' => $options['id']]), ['class' => 'checkbox']); }
public function checkboxList($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) { $checkbox = Html::checkbox($name, $checked, array_merge($itemOptions, ['value' => $value, 'label' => $encode ? Html::encode($label) : $label])); return '<li>' . $checkbox . '</li>'; }; return parent::checkboxList($items, $options); }
/** * @inheritdoc */ protected function renderDataCellContent($model, $key, $index) { $params = is_array($key) ? $key : ['id' => (string) $key]; $params[0] = 'switcher'; $params["attribute"] = $this->attribute; $value = $this->getDataCellValue($model, $key, $index); if (is_string($value)) { $result = $value; } else { $this->registerClientScript(); $result = Html::checkbox('', $value == StatusEnum::STATUS_ON, ['class' => 'js-switch', 'data-url' => Url::to($params), 'data-reload' => $this->reload]); } return $result; }
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'); }
public function init() { parent::init(); if (!$this->hasModel() || !isset($this->model->{$this->attribute}) && !is_null($this->model->{$this->attribute}) || is_null($this->data) && empty($this->attributeLabel)) { throw new InvalidConfigException("Either 'model' and 'attribute' and 'attributeLabel' properties must be specified."); } /** @var ActiveRecord[] $models */ $models = $this->model->{$this->attribute}; if (!$this->data && is_array($models) && current($models) instanceof ActiveRecord) { $primaryKey = $models[0]->primaryKey(); if (!isset($primaryKey[0])) { throw new Exception('"' . get_class($models[0]) . '" must have a primary key.'); } $this->data = ArrayHelper::map($models, $primaryKey[0], $this->attributeLabel); } $this->scriptOptions['data'] = $this->data; if (!isset($this->scriptOptions['templateItem']) || !$this->scriptOptions['templateItem']) { $this->scriptOptions['templateItem'] = Html::tag('li', '{text}' . Html::a(Html::tag('span', '', ['class' => 'glyphicon glyphicon-remove']), '#', ['class' => 'checkbox-multiple-remove-item', 'onclick' => 'return false;']), ['class' => 'checkbox-multiple-item']); } if (!isset($this->scriptOptions['templateCheckbox']) || !$this->scriptOptions['templateCheckbox']) { $this->scriptOptions['templateCheckbox'] = Html::checkbox($this->model->formName() . '[' . $this->attribute . '][]', true, ['value' => '{id}']); } if (!isset($this->scriptOptions['templateResultItem']) || !$this->scriptOptions['templateResultItem']) { $this->scriptOptions['templateResultItem'] = Html::tag('li', '{text}', ['class' => 'checkbox-multiple-result-item']); } if (!isset($this->scriptOptions['templateInput']) || !$this->scriptOptions['templateInput']) { $this->scriptOptions['templateInput'] = Html::textInput('checkbox-multiple-input', '', ['class' => 'form-control']); } if (!isset($this->scriptOptions['errorMessage'])) { $this->scriptOptions['errorMessage'] = Yii::t('app', 'Error'); } if (!isset($this->scriptOptions['templateResultError']) || !$this->scriptOptions['templateResultError']) { $this->scriptOptions['templateResultError'] = Html::tag('li', '{text}', ['class' => 'checkbox-multiple-result-error']); } if (!isset($this->scriptOptions['warningMessage'])) { $this->scriptOptions['warningMessage'] = Yii::t('app', 'No results'); } if (!isset($this->scriptOptions['templateResultWarning']) || !$this->scriptOptions['templateResultWarning']) { $this->scriptOptions['templateResultWarning'] = Html::tag('li', '{text}', ['class' => 'checkbox-multiple-result-warning']); } if (empty($this->placeholder)) { $this->placeholder = Yii::t('app', 'Search ...'); } $this->scriptOptions['templatePlaceholder'] = Html::tag('li', $this->placeholder, ['class' => 'checkbox-multiple-placeholder']); Html::addCssClass($this->options, 'checkbox-multiple'); $this->registerAsset(); $this->registerSlimScrollAsset(); $this->registerClientScript(); }
/** * Renders the widget. */ public function run() { echo Html::tag('label', $this->label, ['class' => 'modal__label', 'for' => 'modal__control--' . $this->id]); $this->_output = Html::beginTag('div'); $this->_output .= Html::checkbox($this->id, false, ['class' => 'modal__control', 'id' => 'modal__control--' . $this->id]); $this->_output .= Html::beginTag('div', ['class' => 'modal__container']); $this->_output .= Html::beginTag('div', $this->options); if (!empty($this->title)) { $this->_output .= Html::tag('div', $this->title, ['class' => 'modal__title']); } $this->_output .= Html::tag('label', $this->close, ['class' => 'modal__close', 'for' => 'modal__control--' . $this->id]); $this->_output .= Html::tag('div', $this->content, ['class' => 'modal__content']); $this->_output .= Html::endTag('div'); $this->_output .= Html::endTag('div'); $this->_output .= Html::endTag('div'); }
/** * Renders the checkbox input */ public function renderCheckbox() { if ($this->inline == true) { Html::addCssClass($this->_internalOptions, 'checkbox-custom checkbox-inline'); echo Html::beginTag('label', $this->_internalOptions) . "\n"; } else { echo Html::beginTag('label', ['class' => 'checkbox-custom']) . "\n"; } if ($this->hasModel()) { echo Html::activeCheckbox($this->model, $this->attribute, $this->options) . "\n"; } else { echo Html::checkbox($this->name, $this->value, $this->options) . "\n"; } echo $this->label . "\n"; echo Html::endTag('label') . "\n"; }
/** * @return string */ public function renderAfterTable() { $id = $this->id; GridViewStandartAsset::register($this->view); $checkbox = Html::checkbox('sx-select-full-all', false, ['class' => 'sx-select-full-all']); $multiActions = []; if ($this->adminController) { $multiActions = $this->adminController->getMultiActions(); } if (!$multiActions) { return parent::renderAfterTable(); } $options = ['id' => $this->id, 'enabledPjax' => $this->enabledPjax, 'pjaxId' => $this->pjax->id, 'requestPkParamName' => $this->adminController->requestPkParamName]; $optionsString = Json::encode($options); $gridJsObject = $this->getGridJsObject(); $this->view->registerJs(<<<JS {$gridJsObject} = new sx.classes.grid.Standart({$optionsString}); JS ); $buttons = ""; $additional = []; foreach ($multiActions as $action) { $additional[] = $action->registerForGrid($this); $buttons .= <<<HTML <button class="btn btn-default btn-sm sx-grid-multi-btn" data-id="{$action->id}"> <i class="{$action->icon}"></i> {$action->name} </button> HTML; } $additional = implode("", $additional); $this->afterTableLeft = <<<HTML {$checkbox} для всех <span class="sx-grid-multi-controlls"> {$buttons} </span> <span style="display: none;">{$additional}</span> HTML; $this->view->registerCss(<<<CSS .sx-grid-multi-controlls { margin-left: 20px; } CSS ); return parent::renderAfterTable(); }
/** * @inheritdoc */ protected function renderDataCellContent($model, $key, $index) { if ($this->checkboxOptions instanceof Closure) { $options = call_user_func($this->checkboxOptions, $model, $key, $index, $this); } else { $options = $this->checkboxOptions; if (!isset($options['value'])) { $options['value'] = is_array($key) ? json_encode($key, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) : $key; } } $checked = false; if ($selectedItem = \stivehu\rangecomp\Rangecomp::rangeDeCompress(Json::decode(\stivehu\enhancedcookie\EnhancedCookie::getBigCookie($this->cookieName)))) { if (in_array($model->id, $selectedItem)) { $checked = true; } } return Html::checkbox($this->name, $checked, $options); }
public function run() { $inputName = Html::getInputName($this->model, $this->attribute); $replace['{hiddenInput}'] = Html::hiddenInput($inputName, ''); if (!empty($this->imageUrl)) { $replace['{image}'] = Html::img($this->imageUrl, $this->imageOptions); $this->checkboxOptions['value'] = FileUploadBehavior::DELETE_VALUE; $replace['{checkbox}'] = strtr($this->checkboxTemplate, ['{checkbox}' => Html::checkbox($inputName, false, $this->checkboxOptions), '{checkboxLabel}' => \Yii::t('yii', 'Delete')]); } else { $replace['{image}'] = ''; $replace['{checkbox}'] = ''; } if ($this->hasModel()) { $replace['{fileInput}'] = Html::activeInput('file', $this->model, $this->attribute, $this->options); } else { $replace['{fileInput}'] = Html::input('file', $this->name, '', $this->options); } echo strtr($this->template, $replace); }
public static function buildHtmlTreeInput($model, $attribute, $data) { $lines = []; if (is_array($data) && count($data) > 0) { $lines[] = '<ul>'; foreach ($data as $k => $v) { $lines[] = '<li>'; $lines[] = '<div class="checkbox icheck">'; $lines[] = Html::checkbox(Html::getInputName($model, $attribute) . '[' . $v['id_pure'] . ']', in_array($v['id_pure'], $model->{$attribute}), ['value' => $v['id_pure'], 'label' => '<span>' . $v['text'] . '</span>']); $lines[] = '</div>'; if (is_array($v['children'])) { $lines[] = self::buildHtmlTreeInput($model, $attribute, $v['children']); } $lines[] = '</li>'; } $lines[] = '</ul>'; } return join("\n", $lines); }
/** * Create a new Term model for hierarchical Taxonomy through AJAX request. */ public function actionAjaxCreateHierarchical() { $item = ''; $term = new Term(); $termRelationship = new TermRelationship(); if ($term->load(Yii::$app->request->post())) { if ($termRelationship->load(Yii::$app->request->post()) && $termRelationship->post_id) { $term->count = 1; if ($term->save()) { $termRelationship->term_id = $term->id; if ($termRelationship->save()) { $item = $item . '<br />' . Html::label(Html::checkbox('termIds[]', true, ['value' => $term->id]) . $term->name); } } } elseif ($term->save()) { $item = $item . '<br />' . Html::label(Html::checkbox('termIds[]', true, ['value' => $term->id]) . $term->name); } } return $item; }