Helping with html5_tools Module for Drupal 7.x

Events happening in the community are now at Drupal community events on www.drupal.org.
You are viewing a wiki page. You are welcome to join the group and then edit it. Be bold!
Posted by ericduran on January 22, 2011 at 6:27pm
Last updated by ericduran on Sat, 2011年01月22日 18:33

At 1st we're starting to make cck widgets for every html5 elements.

We already have the number field in the html5_tools.module file and you can use that as a base for starting the other fields.

If you're interested in what new fields are available take a look at the elements module code, there is not support for email, number, url, color, and range.

Declaring a new widget type.

/**
* Implements hook_field_widget_info().
*/
function html5_tools_field_widget_info() {
return array(
'numberfield' => array( // Machine name of the widget.
'label' => t('Number field'), // The label of the field, this is what's display to the user on the fields management screen.
'field types' => array('number_integer', 'number_decimal', 'number_float'), // The field_types that are allowed to use this widget.
),
);
}

After you have the widget code above you just need to add a

/**
* Implements hook_field_widget_form().
*/
function html5_tools_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
....
//
}

Examples:
http://api.drupal.org/api/drupal/modules--field--modules--text--text.mod...
http://api.drupal.org/api/drupal/modules--field--modules--number--number...

You will also need a

/**
* Implements hook_field_widget_error().
*/
function html5_tools_field_widget_error($element, $error, $form, &$form_state) {
form_error($element['value'], $error['message']);
}

Feel free to edit this wiki to add more info.

HTML5

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

AltStyle によって変換されたページ (->オリジナル) /