Remove name attribute - Form API For PCI compliance reasons, I need to remove the name attribute from a form field.

I have tried:

(1)

$form['field']= array(
    '#name'=&gt;'',
)


(2)

$form['field']= array(
    '#name'=&gt;false,
)


3)

$form['field']= array(
    '#attributes' =&gt; array('name' =&gt; ''),
)


(4)

$form['field']= array(
    '#attributes' =&gt; array('name' =&gt; false),
)


None of the above work (each of the above produce a field with the name attribute present, just empty. I need it removed altogether).

I haven't managed to achive it with the hook_form_alter hook either.

Any ideas?

Thanks
Assuming it's a textfield, I think the simplest way would be via a preprocess on theme_textfield:

function MYMODULE_preprocess_textfield(&amp;$vars) {
  // Identify the element and remove the name property (which will always be present)
  if ($vars['element']['#foo'] == 'bar') {
    unset($vars['element']['#name'];
  }
}


Bear in mind that Drupal won't be able to process the value for that field correctly if you submit the form, but I guess you're submitting this offsite anyway.

If it's not a textfield you should be able to use the same principle with the the theme function for whatever element type you're using.