/** * Create ActiveForm widget. * * @param \yii\widgets\ActiveForm $form * @param \yii\db\ActiveRecord $model Model * @param string $attribute Model attribute */ public function createWidget($form, $model, $attribute) { $widget = $this->getAttributeWidget($model, $attribute); $tableSchema = $model->getTableSchema(); switch ($widget) { case 'widget': echo $this->createField($form, $model, $attribute, [], 'widget'); break; case 'wysiwyg': $options = ['widgetClass' => RedactorWidget::className(), 'settings' => ['minHeight' => 200, 'plugins' => ['video', 'fullscreen']]]; if ($this->redactorImageUpload === true) { $imageOptions = ['settings' => ['imageManagerJson' => Url::to(['model/redactor-list', 'name' => $this->getModelName($model), 'attr' => $attribute]), 'imageUpload' => Url::to(['model/redactor-upload', 'name' => $this->getModelName($model), 'attr' => $attribute]), 'imageUploadErrorCallback' => new JsExpression('function(json) { alert(json.error); }'), 'plugins' => ['imagemanager']]]; $options = ArrayHelper::merge($options, $imageOptions); } if ($this->redactorFileUpload === true) { $fileOptions = ['settings' => ['fileManagerJson' => Url::to(['model/redactor-list', 'name' => $this->getModelName($model), 'attr' => $attribute, 'type' => 'file']), 'fileUpload' => Url::to(['model/redactor-upload', 'name' => $this->getModelName($model), 'attr' => $attribute, 'type' => 'file']), 'fileUploadErrorCallback' => new JsExpression('function(json) { alert(json.error); }'), 'plugins' => ['filemanager']]]; $options = ArrayHelper::merge($options, $fileOptions); } echo $this->createField($form, $model, $attribute, $options, 'widget'); break; case 'date': $options = ['widgetClass' => TimePicker::className(), 'mode' => 'date', 'clientOptions' => ['dateFormat' => 'yy-mm-dd']]; echo $this->createField($form, $model, $attribute, $options, 'widget'); break; case 'time': $options = ['widgetClass' => TimePicker::className(), 'mode' => 'time', 'clientOptions' => ['timeFormat' => 'HH:mm:ss', 'showSecond' => true]]; echo $this->createField($form, $model, $attribute, $options, 'widget'); break; case 'datetime': $options = ['widgetClass' => TimePicker::className(), 'mode' => 'datetime', 'clientOptions' => ['dateFormat' => 'yy-mm-dd', 'timeFormat' => 'HH:mm:ss', 'showSecond' => true]]; echo $this->createField($form, $model, $attribute, $options, 'widget'); break; case 'select': $options = ['options' => ['placeholder' => Yii::t('ycm', 'Choose {name}', ['name' => $model->getAttributeLabel($attribute)])], 'settings' => ['allowClear' => true, 'width' => '100%'], 'items' => ['' => '']]; echo $this->createField($form, $model, $attribute, $options, 'select'); break; case 'selectMultiple': $options = ['options' => ['multiple' => true, 'placeholder' => Yii::t('ycm', 'Choose {name}', ['name' => $model->getAttributeLabel($attribute)])], 'settings' => ['width' => '100%']]; echo $this->createField($form, $model, $attribute, $options, 'select'); break; case 'image': $options = []; if (!$model->isNewRecord && !empty($model->{$attribute})) { $className = StringHelper::basename($model->className()); $inputName = $className . '[' . $attribute . '_delete]'; $inputId = strtolower($className . '-' . $attribute . '_delete'); $url = $this->getAttributeUrl($this->getModelName($model), $attribute, $model->{$attribute}); ob_start(); echo '<div class="checkbox"><label for="' . $inputId . '"> <input type="checkbox" name="' . $inputName . '" id="' . $inputId . '" value="delete"> ' . Yii::t('ycm', 'Delete image') . ' </label></div>'; Modal::begin(['size' => Modal::SIZE_LARGE, 'header' => '<h4>' . Yii::t('ycm', 'Preview image') . '</h4>', 'toggleButton' => ['label' => Yii::t('ycm', 'Preview image'), 'class' => 'btn btn-info btn-sm']]); echo Html::img($url, ['class' => 'modal-image']); Modal::end(); $html = ob_get_clean(); $options['hint'] = $html; } echo $this->createField($form, $model, $attribute, $options, 'fileInput'); break; case 'file': $options = []; if (!$model->isNewRecord && !empty($model->{$attribute})) { $className = StringHelper::basename($model->className()); $inputName = $className . '[' . $attribute . '_delete]'; $inputId = strtolower($className . '-' . $attribute . '_delete'); $url = $this->getAttributeUrl($this->getModelName($model), $attribute, $model->{$attribute}); $html = '<div class="checkbox"><label for="' . $inputId . '"> <input type="checkbox" name="' . $inputName . '" id="' . $inputId . '" value="delete"> ' . Yii::t('ycm', 'Delete file') . ' </label></div>'; $html .= Html::a(Yii::t('ycm', 'Download file'), $url, ['class' => 'btn btn-info btn-sm']); $options['hint'] = $html; } echo $this->createField($form, $model, $attribute, $options, 'fileInput'); break; case 'text': $options = ['maxlength' => $tableSchema->columns[$attribute]->size]; echo $this->createField($form, $model, $attribute, $options, 'textInput'); break; case 'hidden': $options = ['maxlength' => $tableSchema->columns[$attribute]->size]; $options = $this->getAttributeOptions($attribute, $options); echo Html::activeHiddenInput($model, $attribute, $options); break; case 'password': $options = ['maxlength' => $tableSchema->columns[$attribute]->size]; echo $this->createField($form, $model, $attribute, $options, 'passwordInput'); break; case 'textarea': $options = ['rows' => 6]; echo $this->createField($form, $model, $attribute, $options, 'textarea'); break; case 'radio': echo $this->createField($form, $model, $attribute, [], 'radio'); break; case 'boolean': case 'checkbox': echo $this->createField($form, $model, $attribute, [], 'checkbox'); break; case 'dropdown': $options = ['prompt' => Yii::t('ycm', 'Choose {name}', ['name' => $model->getAttributeLabel($attribute)])]; echo $this->createField($form, $model, $attribute, $options, 'dropDownList'); break; case 'listbox': $options = ['prompt' => '']; echo $this->createField($form, $model, $attribute, $options, 'listBox'); break; case 'checkboxList': echo $this->createField($form, $model, $attribute, [], 'checkboxList'); break; case 'radioList': echo $this->createField($form, $model, $attribute, [], 'radioList'); break; case 'disabled': $options = ['maxlength' => $tableSchema->columns[$attribute]->size, 'readonly' => true]; echo $this->createField($form, $model, $attribute, $options, 'textInput'); break; case 'hide': break; default: $options = $this->getAttributeOptions($attribute); echo $form->field($model, $attribute)->{$widget}($options); break; } }
?> <?php echo $form->field($model, 'unit')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'place')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'start_time')->widget(\janisto\timepicker\TimePicker::className(), ['mode' => 'datetime', 'clientOptions' => ['dateFormat' => 'yy-mm-dd', 'timeFormat' => 'HH:mm', 'showSecond' => false]]); ?> <?php echo $form->field($model, 'stop_time')->widget(\janisto\timepicker\TimePicker::className(), ['mode' => 'datetime', 'clientOptions' => ['dateFormat' => 'yy-mm-dd', 'timeFormat' => 'HH:mm', 'showSecond' => false]]); ?> <?php echo $form->field($model, 'contact')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'contact_method')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'summary')->textarea(['maxlength' => true, 'rows' => '3']); ?> <?php
<?php $form = ActiveForm::begin(); ?> <div class="col-md-6"> <?php echo $form->field($model, 'image', ['template' => '{label}<div class="picturecut_image_container" ' . (!$model->isNewRecord ? 'style="background-image:url(' . $model->getImage() . ')"' : '') . '></div>{input}{error}{hint}'])->textInput(['maxlength' => true, 'readonly' => true, 'type' => 'hidden']); ?> <?php // echo $form->field($model, 'image_path')->textInput(['maxlength' => true, 'readonly' => true]) ?> <?php $model->dob = date('d-m-Y', $model->dob); ?> <?php echo $form->field($model, 'dob')->widget(TimePicker::className(), ['language' => 'vi', 'mode' => 'date', 'clientOptions' => ['dateFormat' => 'dd-mm-yy', 'showSecond' => true]]); ?> <?php echo $form->field($model, 'gender')->dropDownList([User::GENDER_MALE => 'Nam', User::GENDER_FEMALE => 'Nữ', User::GENDER_OTHER => 'Khác'], ['prompt' => '']); ?> </div> <div class="col-md-6"> <?php echo $form->field($model, 'username')->textInput(['maxlength' => true, 'readonly' => !$model->isNewRecord]); ?> <?php // echo $form->field($model, 'auth_key')->textInput(['maxlength' => true]) ?> <?php // echo $form->field($model, 'password_hash')->textInput(['maxlength' => true])
]) */ ?> <?php // echo $form->field($model, 'updated_by')->textInput(['maxlength' => true, 'readonly' => true, 'value' => !$model->isNewRecord ? $username : '' ]) ?> <?php // echo $form->field($model, 'status')->textInput() ?> <?php // echo $form->field($model, 'position')->textInput() ?> <?php $model->published_at = $model->isNewRecord ? date('Y-m-d H:i:00') : date('Y-m-d H:i:s', $model->published_at); ?> <?php echo $form->field($model, 'published_at')->widget(TimePicker::className(), ['language' => 'vi', 'mode' => 'datetime', 'clientOptions' => ['dateFormat' => 'yy-mm-dd', 'timeFormat' => 'HH:mm:ss', 'showSecond' => true]]); ?> <?php echo $form->field($model, 'is_active')->checkbox(); ?> <?php echo $form->field($model, 'is_hot')->checkbox(); ?> </div> <div class="col-md-6"> <?php echo $form->field($model, 'code')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'slug')->textInput(['maxlength' => true]);
use yii\helpers\Html; use yii\widgets\ActiveForm; /* @var $this yii\web\View */ /* @var $model app\models\Calendar */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="calendar-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'date_event')->widget(\janisto\timepicker\TimePicker::className(), ['attribute' => 'date_event', 'value' => 'date_event', 'mode' => 'datetime', 'clientOptions' => ['placeholder' => 'Please, select a planned date ...', 'todayHighlight' => true, 'class' => 'form-control', 'dateFormat' => 'yy-mm-dd', 'timeFormat' => 'HH:mm:ss', 'showSecond' => true], 'language' => 'ru']); ?> <?php echo $form->field($model, 'text')->textarea(['rows' => 6]); ?> <!--<?php echo $form->field($model, 'creator')->textInput(); ?> --> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?>