Active form html5 input types such as email and number

HTML5 text input types are supported in YII2. These types include:

  • color
  • date
  • datetime
  • datetime-local
  • email
  • month
  • number
  • range
  • search
  • tel
  • time
  • url
  • week

With YII2 you can specify the input type as this:

  1. $form->field($model, 'email')->input('email')

This would set the input type to ’email’ which is useful for mobile apps. This will bring up the e-mail keyboard. The number keyboard can also be supported by using input(‘number’).