1

I have a yii2 ActiveForm field with a HTML5 "form" attribute like this:

$form->field($model, 'event_date', [
    'inputOptions' => ['form' => 'starterWizard__form']
])->label('Enter date:');

If I apply a jQueryUI datepicker to this field in yii2 like below, the "form" attribute no longer gets inserted on input field.

$form->field($model, 'event_date', [
    'inputOptions' => ['form' => 'starterWizard__form']
])->label('Enter date:')->widget(\yii\jui\DatePicker::class, ['dateFormat' => 'yyyy-MM-dd']);

Any idea why the widget removes "form" attribute from input field and how I can fix the issue?

1

1 Answer 1

0

When using widget to render a dynamic tag, it's moved away from the form and is only accessible in the controller via the $_POST[] array,

you will have to use

$model->attributes

and before that check :

isset($_POST['ModelName'])
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.