Quick and dirty patch to add maxlength as an option on textfields.
@@ -28,6 +28,15 @@ '#maxlength' => 10, '#weight' => 0, ); + $editFields['extra']['maxlength'] = array ( + '#type' => 'textfield', + '#title' => t("Maxlength"), + '#default_value' => $currfield['extra']['maxlength'], + '#description' => t('Maxlength of the textfield.'), + '#size' => 5, + '#maxlength' => 10, + '#weight' => 1, + ); $editFields['extra']['attributes']['disabled'] = array ( '#type' => 'checkbox', '#title' => t("Disabled"), @@ -61,6 +70,9 @@ if ($component['extra']['width'] > 0) { $formItem['#size'] = $component['extra']['width']; } + if ($component['extra']['maxlength'] > 0) { + $formItem['#maxlength'] = $component['extra']['maxlength']; + } return $formItem; }
Comments
Comment #1
quicksketchThanks Mike! Could you post the patch in the Unified format (with the -u flag)?
Comment #2
BioALIEN commentedMikegull, +1 for this patch, it answers a feature request I posted about this. Ideally it should support minimum and maximum just like CCK module.
quicksketch, I believe this should be patched against the 5.x version then ported back to 4.7.x?
I think we need to have a clear version which contains all the latest features, in this case its the 5.x branch and the most popular of these may be ported back based on demand. I believe this will organise everything and be inline with the Drupal way of development. What's your opinion on this?
Comment #3
quicksketchYes, making a new official release wouldn't be a bad idea. Most patches like this one apply easily to 4.7 and 5 branches and I try to keep them in sync at the moment.
Comment #4
quicksketchI ended up patching by hand, please post complete patches in the future. Thanks for your contribution!
Comment #5
(not verified) commented