Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
API page: http://api.drupal.org/api/drupal/modules%21field%21field.api.php/functio...
See the last comment at http://api.drupal.org/api/drupal/modules%21field%21field.api.php/functio..., and also core's implementations of this hook.
It appears it is never correct to just do 'return $element' as this leads to the bug of only the first character of the textfield being saved. Hence the example code is misleading.
Comment | File | Size | Author |
---|---|---|---|
#2 | field_api_example-1857984-2.patch | 459 bytes | Ivan Zugec |
Comments
Comment #1
jhodgdonYeah, it should return an array of elements. Probably the easiest way to fix it would be to change the last line to be (as in number_field_widget_form() for instance):
That would be a good Novice project... And this hook doesn't exist any more in Drupal 8.x, so this is purely a 7.x issue.
Comment #2
Ivan Zugec CreditAttribution: Ivan Zugec commentedUpdated what is returned in hook_field_widget_form.
Comment #3
jhodgdonLooks good -- thanks for the patch!
Comment #4
jhodgdonCommitted to 7.x. Thanks again!