Remove field attributes using hook_form_alter() How do I remove form element attributes from a form using hook_form_alter()?
For example, given the following HTML markup, how do I remove form-text?
&lt;input type=&quot;text&quot; class=&quot;form-text required&quot; maxlength=&quot;255&quot; size=&quot;60&quot; value=&quot;&quot; name=&quot;title&quot; id=&quot;edit-title&quot;&gt;
Insert the following into your custom module:

function YOUR_MODULE_form_alter(&amp;$form, &amp;$form_state, $form_id){
  switch($form_id){
    case 'YOUR_FORM_ID':
      $form['title']['#required'] =&gt; FALSE;
      break;
  }
  return $form;
}


That makes the title field optional. You can check the different form element types and the properties that go with them here: https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/7

And you can read more about hook_form_alter here: https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_form_alter/7