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.

#2 field_api_example-1857984-2.patch459 bytesIvan Zugec
PASSED: [[SimpleTest]]: [MySQL] 39,558 pass(es). View


jhodgdon’s picture

Version: 8.x-dev » 7.x-dev
Issue tags: +Novice

Yeah, 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):

return array('value' => $element);

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.

Ivan Zugec’s picture

Status: Active » Needs review
459 bytes
PASSED: [[SimpleTest]]: [MySQL] 39,558 pass(es). View

Updated what is returned in hook_field_widget_form.

jhodgdon’s picture

Status: Needs review » Reviewed & tested by the community

Looks good -- thanks for the patch!

jhodgdon’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 7.x. Thanks again!

Automatically closed -- issue fixed for 2 weeks with no activity.