Closed kartik-v closed 8 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.
@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.
@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.
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.
most of this is supported by Html already. One can use Html::tag and in some widgets support for custom tags is already supplied.
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.