2

I have thousabds of field for admin to edit data which is saved in db from mobile app. i can fetch those data into text field while editing but drupal having default #maxlength of 128 character but in my case i have data field which is more than 128 character so its creating problem while saving those data in db. Pls help.. i tried to hack drupal core by writing code in from.inc.

function theme_textfield($variables) {
   $element = $variables['element'];
   $element['#attributes']['type'] = 'text';
+  // Remove maxlength when it's too long to be useful. 
+  if ($element['#maxlength'] >= 128) {
+    unset($element['#maxlength']);
+  }
   element_set_attributes($element, array('id', 'name', 'value', 'size', 'maxlength', 'placeholder'));
   _form_set_class($element, array('form-text'));

but it dint work. pls tell me any solution.

2
  • Which form are you using? Any custom form of drupal build in form ??
    – Rupesh
    Commented Jun 10, 2016 at 5:38
  • i created form using hook_form. Can you please tell me how do i change default #maxlength of textfiled. If you have any idea of removing this attribute that will also work for me. @rupesh Commented Jun 10, 2016 at 5:41

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.