Currently the search field has a maxlength of 128, I am wondering if there is any way to increase it too maybe 255?
1 Answer
Yes but it's not pretty. Drupal really doesn't want you to change field definitions after they've been created.
The correct way would be to create a new field definition and migrate values from the old field into the new one.
The quick and dirty way would be to manually change the field definition in the database directly.
The quick and dirty way that is deployable via code is to do a two-step process:
- Export the field (such as with Features) and alter the
#maxlength
setting in the code. - TEMPORARILY hack core by commenting out the code in
hook_field_update_forbid()
in field.api.php. - Deploy a tag containing 1 and 2. Run updates.
- UNCOMMENT
hook_field_update_forbid
and deploy that tag so further changes are not allowed and core is put back in its natural state.
This is terrible but I have done it and it works.
hook_form_alter
and changing the#size
property of the textfield? api.drupal.org/api/drupal/…#maxlength
, not#size
)hook_form_alter()
to increase#maxlength
as @Clive and @rwaery have suggested.