/** * @param $item * @return string */ public static function settingField($key, $item, $traslateCategory) { $return = ''; switch ($item['type']) { case 'checkbox': $return = parent::beginTag('div', ['class' => 'form-group']) . parent::beginTag('label', ['class' => 'col-md-3 control-label']) . \Yii::t($traslateCategory, $key) . parent::endTag('label') . parent::beginTag('div', ['class' => 'col-md-9']) . parent::hiddenInput('Settings[' . $key . ']', 0) . \oakcms\bootstrapswitch\Switcher::widget(['id' => 'wid' . uniqid(), 'name' => 'Settings[' . $key . ']', 'checked' => $item['value']]) . parent::endTag('div') . parent::endTag('div'); break; case 'textInput': $return = parent::beginTag('div', ['class' => 'form-group']) . parent::beginTag('label', ['class' => 'col-md-3 control-label']) . \Yii::t($traslateCategory, $key) . parent::endTag('label') . parent::beginTag('div', ['class' => 'col-md-9']) . parent::textInput('Settings[' . $key . ']', $item['value'], ['class' => 'form-control']) . parent::endTag('div') . parent::endTag('div'); break; case 'textarea': $return = parent::beginTag('div', ['class' => 'form-group']) . parent::beginTag('label', ['class' => 'col-md-3 control-label']) . \Yii::t($traslateCategory, $key) . parent::endTag('label') . parent::beginTag('div', ['class' => 'col-md-9']) . parent::textarea('Settings[' . $key . ']', $item['value'], ['class' => 'form-control']) . parent::endTag('div') . parent::endTag('div'); break; case 'mediaInput': $return = parent::beginTag('div', ['class' => 'form-group']) . parent::beginTag('label', ['class' => 'col-md-3 control-label']) . \Yii::t($traslateCategory, $key) . parent::endTag('label') . parent::beginTag('div', ['class' => 'col-md-9']) . InputFile::widget(['id' => 'wid' . uniqid(), 'language' => \Yii::$app->language, 'filter' => 'image', 'name' => 'Settings[' . $key . ']', 'value' => $item['value']]) . parent::endTag('div') . parent::endTag('div'); break; default: $return = ''; break; } return $return; }
echo $form->field($model, 'language')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'country')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'url')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'name')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'name_ascii')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'status')->widget(\oakcms\bootstrapswitch\Switcher::className()); ?> <?php ActiveForm::end(); ?> </div> <script> function sendFormReload(elm) { $(elm).append($("<input type='hidden' name='submit-type' value='continue'>")); $(elm).submit(); return false; } </script>
</label> <?php echo Html::input('text', 'Settings[' . $key . ']', $value['value'], ['class' => 'form-control']); ?> </div> <?php } elseif ($value['type'] == 'checkbox') { ?> <div class="checkbox form-controll row"> <label class="col-sm-3"><?php echo Yii::t('admin', $key); ?> </label> <div class="col-sm-9"> <?php echo Html::hiddenInput('Settings[' . $key . ']', 0) . \oakcms\bootstrapswitch\Switcher::widget(['name' => 'Settings[' . $key . ']', 'checked' => $value['value']]); ?> </div> </div> <?php } else { ?> <?php } ?> <?php } ?> <?php Html::endForm();
/** * @return string */ public function renderField() { switch ($this->type) { case 'textInput': return Html::textInput($this->param_name, $this->param_value, ['class' => 'form-control']); break; case 'textarea': return Html::textarea($this->param_name, $this->param_value, ['class' => 'form-control']); break; case 'checkbox': return Html::hiddenInput($this->param_name, 0) . \oakcms\bootstrapswitch\Switcher::widget(['name' => $this->param_name, 'checked' => $this->param_value]); break; case 'language': return Html::dropDownList($this->param_name, $this->param_value, ArrayHelper::map(Language::getLanguages(), 'language_id', 'name'), ['class' => 'form-control']); break; case 'getTheme': $files = scandir(Yii::getAlias('@app') . '/templates/frontend'); $items = []; foreach ($files as $file) { //if(!is_file($file) AND $file != '.' AND $file != '..') { if ($file != '.' and $file != '..') { $items[$file] = $file; } } return Html::dropDownList($this->param_name, $this->param_value, $items, ['class' => 'form-control']); break; } }