0

I'm using a Drupal 6 custom form, and I want to change the form name attribute to something else. Is this possible?

For example, I have this.

<input type="text" name="field" maxlength="128" id="edit-name" value="">

I want to change it to the following.

<input type="text" data-name="field" maxlength="128" id="edit-name" value="">
Sasindu H
  • 1,538
  • 7
  • 24
  • 43

1 Answers1

0

You can add the new attribute by using hook_form_alter() and adding a #data-name to the array for the field you are trying to update. I don't think you can easily remove the name attribute in Drupal 6, but I've never tried. More on the Drupal 6 Form API.

Take Note: Drupal 6 is no longer officially supported by the community. While there are some places that are offering long term support for Drupal 6, you should plan to move to Drupal 7 or 8 soon.

acrosman
  • 12,814
  • 10
  • 39
  • 55
  • Thanks for the answer. But I need to remove the name attribute. – Sasindu H May 18 '16 at 05:04
  • You can try to set the #name to an empty string or false and see if it gets removed (https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/6.x#name). If that doesn't work I think to remove that attribute altogether you'll need to override the theme function for the form fields. – acrosman May 18 '16 at 21:53