简体   繁体   中英

Adding rel attribute to Drupal form submit button

For some reason I cannot make this work. The rel attribute does not get added to the input tag.

function voicesofyouth_preprocess_contestentry_node_form(&$vars){

    $vars['form']['buttons']['submit']['#attributes']= array("rel"=>"draft"); 
    //Does not work

    $vars['form']['buttons']['submit']['#attributes']= array("class"=>"draft");
    //But adding a class does work

}

Does anyone know why this is happening? I am completely dumbfounded as to why adding the class works but the rel does not.

if that code is the exact one as in your module then it's not working because on the second line you actually delete the '#attributes' property you set up in the first line. you should write something like this:

$vars['form']['buttons']['submit']['#attributes'] = array(
  "rel" => "draft",
  "class" => "draft"
); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM