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’).

Published by

Joel Bowers

Web developer since 1999. PHP, YII2, Laravel, Javascript, HTML, CSS, jQuery, Perl, Wordpress, MySQL.

Leave a Reply

Your email address will not be published. Required fields are marked *