Changing easily 'type' in FormField

Hi all,

I have a simple ActiveForm in which I set


<?= $form->field($model, 'email') ?>

but the generated code set ‘type’ to text. And I wonder if it would be possible to set it to ‘email’.

I have:


<input type="text" id="identityform-email" class="form-control" name="IdentityForm[email]">

I would like:


<input type="email" id="identityform-email" class="form-control" name="IdentityForm[email]">

Same problem for date (would like a type=“date” instead of type =‘text’ in the generated input code)

I try to use


<?= $form->field($model, 'email',['type'=>'email']) ?>

but I end up with an exception (Unknown Property)

Do you know if it is possible to change this ?

Thx in advance




//Type email

<?= $form->field($model, 'email')->input('email', $htmlOptions) ?>

//Type date

<?= $form->field($model, 'email')->input('date') ?>

//Type text

<?= $form->field($model, 'email')->textInput() ?>

//Type number

<?= $form->field($model, 'email')->input('number') ?>

//Type file

<?= $form->field($model, 'email')->fileInput() ?>


//And more...



The function field() returns an instance of yii\widgets\ActiveField

ActiveField doc : http://www.yiiframework.com/doc-2.0/yii-widgets-activefield.html

Or an other way to do the same thing :




<?= $form->field($model, 'email',['inputOptions' => ['type'=>'email']]) ?>



Merci Timmy du 78