1

I have found lots of resources about using HTML5 elements in custom forms (via Form API or using elements module). What's the standard technique which implements HTML5 field widgets (e.g. for a node field)?

For example, I have an "integer" field on node type "article" for which i want to use an HTML5 "number" input type. The only widget available to Fields API for data type number_integer is "textfield".

1 Answer 1

1

Your question is not clear please explain what HTML5 element you want to add to the form field. If you want to add placeholder or any other element you can pass them in #attributes, like this:

$form['name'] = array( '#type' => 'textfield', '#title' => t('First Name'), '#attributes' => array('placeholder' => 'First Name'), );

1
  • I'm using elements module for HTML5 inputs in Form API - no problems there. I'm looking for a module to provide HTML5 widgets to Fields API. Commented Sep 14, 2017 at 13:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.