I am working on a project where i need to port a custom field created in d6 to d7. This field was implementing a hook_widget.
Can anyone tell me开发者_运维问答 the replacement for this in drupal 7?
Thanks
hook_widget()
has been renamed to hook_field_widget_form()
in Drupal 7. There's also some new arguments for it.
http://api.drupal.org/api/drupal/modules--field--field.api.php/function/hook_field_widget_form/7
<?php
/**
* Implements hook_field_widget_form().
*/
function number_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
// use += to avoid overwriting incoming $element
$element['value'] += array(
// Fill in $element.
);
return $element;
}
/**
* Implements hook_field_widget_error().
*/
function number_field_widget_error($element, $error, $form, &$form_state) {
form_error($element['value'], $error['message']);
}
?>
@See http://drupal.org/node/728792
精彩评论