You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have question
I use this code
Address ';
$editable = Editable::begin([
'model'=>$model,
'attribute'=>'address',
'size'=>'md',
'displayValue' => '15th Main, OK, 10322',
'options'=>['placeholder'=>'Enter address...']
]);
$form = $editable->getForm();
echo Html::hiddenInput('kv-complex', '1');
$editable->afterInput =
$form->field($model, 'province_id')->widget(\kartik\widgets\Select2::classname(), [
'data'=>ArrayHelper::map($modelProvince, 'province_id', 'province_name'),
'options'=>['placeholder'=>'Enter province...'],
'pluginOptions'=>['allowClear'=>true]
]) . "\n" .
$form->field($model, 'zipcode')->textInput(['placeholder'=>'Enter zip code...']);
Editable::end();
?>
When I submit data, in Controller I validate data by use below function.
ActiveForm::validate($model)
and return validated data as below
{"usershop-address":["Address cannot be blank."],"usershop-province_id":["Province cannot be blank."],"usershop-zipcode":["Zipcode cannot be blank."]}
Question is, How to show each error message to each input field?
Thanks,
The text was updated successfully, but these errors were encountered:
You should use ideally yii model validation rules for each attribute for the above... and not use Controller to validate this. Read about yii model validation rules in yii guides where you can set required property for each attribute to achieve what you want.
I have question
I use this code
Address
'; $editable = Editable::begin([ 'model'=>$model, 'attribute'=>'address', 'size'=>'md', 'displayValue' => '15th Main, OK, 10322', 'options'=>['placeholder'=>'Enter address...'] ]); $form = $editable->getForm(); echo Html::hiddenInput('kv-complex', '1'); $editable->afterInput = $form->field($model, 'province_id')->widget(\kartik\widgets\Select2::classname(), [ 'data'=>ArrayHelper::map($modelProvince, 'province_id', 'province_name'), 'options'=>['placeholder'=>'Enter province...'], 'pluginOptions'=>['allowClear'=>true] ]) . "\n" . $form->field($model, 'zipcode')->textInput(['placeholder'=>'Enter zip code...']); Editable::end(); ?>
When I submit data, in Controller I validate data by use below function.
ActiveForm::validate($model)
and return validated data as below
{"usershop-address":["Address cannot be blank."],"usershop-province_id":["Province cannot be blank."],"usershop-zipcode":["Zipcode cannot be blank."]}
Question is, How to show each error message to each input field?
Thanks,
The text was updated successfully, but these errors were encountered: