The various 'settings form' for field settings, widget settings, formatter settings, frequently need basic validation rules like 'number', 'integer', 'positive integer'...

To avoid each field type module redefining those functions over and over, CCK D6 defined generic validator functions :
_element_validate_number(), _element_validate_integer(), _element_validate_integer_positive().

They stayed in Field UI during the D7 conversion - not in the .module, but in field_ui.admin.inc, not always loaded).

However, the forms that use those functions can appear outside of Field UI, and even when Field IU is disabled, e.g formatter settings when configuring field display in Views (#884730: Add new UI for formatter settings options to the field settings panel).

Attached patch moves them to field.module (arguably they could belong in form.inc, but I prefer to keep that door closed for now).

major, because this blocks the Views patch above (well, it redeclares the functions if they don't exist, but it's an ugly hack).

CommentFileSizeAuthor
field_validator_helpers.patch2.55 KByched

Comments

wundo’s picture

Priority: Major » Critical

Just tested your patch and it's working perfectly here, also this just reminds me of webchick's issue (http://drupal.org/node/937814) from last week talking about all those UI modules that are being made.

wundo’s picture

Status: Active » Reviewed & tested by the community
effulgentsia’s picture

Priority: Critical » Major

I agree with this being RTBC, but not with it being "critical". Anyway, a totally logical patch, and helping Views module and other modules avoid needless duplication is a wonderful thing.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, field_validator_helpers.patch, failed testing.

yched’s picture

Status: Needs work » Needs review

Test bot hiccup ? Patch is harmless, and the failed tests above pass on my local setup.

field_validator_helpers.patch queued for re-testing.

effulgentsia’s picture

Status: Needs review » Reviewed & tested by the community

Bot seems happy again: http://qa.drupal.org/pifr/test/99489

dries’s picture

Priority: Major » Normal
Status: Reviewed & tested by the community » Fixed

Committed to CVS HEAD. Thanks.

Status: Fixed » Closed (fixed)

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