示例#1
0
/* @var $this yii\web\View */
/* @var $model app\models\Departments */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="departments-form">
    <?php 
$form = ActiveForm::begin();
?>
    <?php 
echo $form->field($model, 'name')->textInput(['maxlength' => true]);
?>
    
    <?php 
echo $form->field($model, 'group_id')->widget(Select2::classname(), ['data' => ArrayHelper::map(app\models\Groups::find()->all(), 'id', 'name'), 'language' => 'th', 'options' => ['placeholder' => 'เลือกกลุ่มงาน ...'], 'pluginOptions' => ['allowClear' => true]]);
?>
    
    <?php 
echo $form->field($model, 'rate1')->widget(StarRating::className(), ['pluginOptions' => ['size' => 'md', 'showCaption' => FALSE]]);
?>
    
    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>
    <?php 
ActiveForm::end();
?>
</div>

示例#2
0
 /**
  * Формирование Html кода поля для вывода в форме
  * @param ActiveForm $form объект форма
  * @param array $options массив html атрибутов поля
  * @param bool|int $index инднкс модели при табличном вводе
  * @return string
  */
 public function renderInput(ActiveForm $form, array $options = [], $index = false)
 {
     $options = ArrayHelper::merge($this->options, $options);
     $widgetOptions = ArrayHelper::merge(["options" => ["class" => "form-control"]], $this->widgetOptions, ["options" => $options]);
     return $form->field($this->modelField->model, $this->getFormAttrName($index, $this->modelField->attr))->widget(StarRating::className(), $widgetOptions);
 }