public function rules() { return [['organizaciyaDir', ComboValidator::className(), 'directoryAttribute' => 'organizaciyaDir', 'required' => true], ['org_tip', EnumValidator::className(), 'enumClass' => OrgTipRaboty::className()], ['telefon', TelefonValidator::className(), 'sqlAttribute' => 'telefon']]; }
public function asOrgTipRaboty($value) { return static::asEnum($value, OrgTipRaboty::className()); }
use app\widgets\ComboWidget; use app\widgets\TelefonInput; use yii\bootstrap\ActiveForm; use yii\helpers\Html; /** * @var $model RabotaForm */ ?> <?php $form = ActiveForm::begin(['layout' => 'horizontal']); ?> <?php echo $form->field($model, 'organizaciyaDir')->widget(ComboWidget::className(), ['data' => Organizaciya::find()->commonOnly()->formattedAll(EntityQuery::DROP_DOWN, 'nazvanie')]); ?> <?php echo $form->field($model, 'org_tip')->dropDownList(OrgTipRaboty::namesMap()); ?> <?php echo $form->field($model, 'telefon')->widget(TelefonInput::className()); ?> <?php echo Html::submitButton('Сохранить', ['class' => 'btn btn-primary']); ?> <?php ActiveForm::end();