Advertisement
Guest User

Untitled

a guest
Jan 18th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. <input type="text" alt="abc">
  2.  
  3. function theme_form_alter(&$form, &$form_state, $form_id) {
  4. foreach($form["submitted"] as $newForm)
  5. {
  6. foreach($newForm as $keyid=>$frmArr)
  7. {
  8. if(isset($frmArr[]["#attributes"]["alt"]))
  9. {
  10. $alt = $frmArr["#attributes"]["alt"];
  11. unset($newForm[$keyid]["#attributes"]["alt"]);
  12. $newForm[$keyid]["#attributes"]["data-alt"] = $alt;
  13. }
  14. }
  15. }
  16. }
  17.  
  18. foreach($form["submitted"] as $newForm)
  19. {
  20.  
  21. foreach($newForm as $keyid=>$frmArr)
  22. {
  23. if($keyid=='#attributes'){
  24. $newForm[$keyid]['data-alt']=$newForm[$keyid]['alt'] ;
  25. unset($newForm[$keyid]['alt'] );
  26. $form["submitted"]['#attributes']['alt'] = array("sss");
  27. form_set_value($form["submitted"]['#attributes']['alt'], array("aaa"), $form_state);
  28. }
  29. }
  30.  
  31.  
  32. }
  33.  
  34. function act_form_alter(&$form, &$form_state, $form_id) {
  35. if ($form_id == 'the_id_of_your_form') {
  36. unset($form['submitted']['#attributes']['alt']);
  37. $form['submitted']['#attributes']['data-alt'] = 'abc';
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement