0

How to remove the field attributes from form in hook_form_alter. like

<input type="text" class="form-text required" maxlength="255" size="60" 
value="" name="title" id="edit-title"> 

EX: class:form-text required remove form my article form .

May i check jquery or drupal hard code .what i am doing?

       $('.form-text required').removeAttr('class') 
       But 
       Drupal: If any hard code in hook_form_alter  

Plz give coding sample

0

Insert the following into your custom module:

function YOUR_MODULE_form_alter(&$form, &$form_state, $form_id){
  switch($form_id){
    case 'YOUR_FORM_ID':
      $form['title']['#required'] => 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.