JUI datepicker removes HTML attribute from input field

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?

Hi @smohadjer,

I confirmed the problem. \yii\jui\DatePicker failed to honor inputOptions. I think it’s a bug.

Meanwhile, this may be a workaround:

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

Thanks, your workaround solved my problem. I had tried “clientOptions” instead of “options”, and were getting errors.