yiisoft / yii2

Yii 2: The Fast, Secure and Professional PHP Framework
http://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
14.24k stars 6.9k forks source link

ActiveForm & ActiveField Support for HTML 5 Form Elements #1418

Closed kartik-v closed 8 years ago

kartik-v commented 10 years ago

Can we plan ActiveForm & ActiveField support for new HTML5 form elements like <output> , <datalist>, or <keygen>? Most browsers support these (except the odd IE). This is more a proposal - not essentially an issue.

armpogart commented 10 years ago

Also there are many input types that are used in modern browsers, such as email, url, number etc. Those input types are already used on many websites and has built in client-side validation.

kartik-v commented 10 years ago

@armpogart the HTML 5 input types are supported in Yii already ... you can use Html::input($type) or for ActiveField it is $form->field($model, $attribute)->input($type); Refer earlier closed issue #1022 .

If you still need enhancements w.r.t to HTML 5 inputs for Twitter Bootstrap, I have created a separate extension for HTML 5 inputs to cater to the bootstrap horizontal form styling. You can for example take a look at the enhanced HTML 5 range slider input.

armpogart commented 10 years ago

@kartik-v Oh, thanks. I haven't noticed the availability to explicitly mention input type. As for other elements such as <datalist>, <output> and etc., maybe for now stick with extending some core classes to provide that functionality when needed or separate extensions, as mentioned tags are used very rare currently and many developers even don't know about their existence, so it will add unnecessary code to core Yii2 if only it won't be some generic function to generate those fields.

kartik-v commented 10 years ago

The major one amongst the three is <output> because it is an extended calculated form element. The model attributes to generate will be a bit tricky for an output with ActiveField. The for method for output is an array or space separated attributes and we may need to tweak the form's oninput method to reach the calculation. Otherwise we just need to use custom Html Markup anyway for every scenario to generate such elements. The proposed advantage (limited though)... is that using output uses Html markup versus javascript to generate and display dynamic outputs... should be useful in specific scenarios.

dynasource commented 8 years ago

most of this is supported by Html already. One can use Html::tag and in some widgets support for custom tags is already supplied.