Advertisement
Guest User

Untitled

a guest
Oct 28th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. //form hook, form elements start here
  2.  
  3. function form_casl_form($form, &$form_state) {
  4. //sometext here
  5. $form['some_text'] = array(
  6. '#markup' => '<p><b>Simply click the button to subscribe.</b>
  7. </p>'
  8. );
  9.  
  10.  
  11. //submit button
  12. $form['submit_button'] = array(
  13. '#type' => 'submit',
  14. '#value' => t('Subscribe'),
  15.  
  16. );
  17. return $form;
  18. }
  19. //validate hook
  20.  
  21. $form['#attached']['js'][] = drupal_get_path('module', 'YOURMODULE') . '/YOURMODULE.js';
  22.  
  23. Drupal.behaviors.YOURMODULE = {
  24. attach: function(context, settings) {
  25. $('.your-form-selector', context).once('YOURMODULE').delay(10000).submit();
  26. }
  27. }
  28.  
  29. /**
  30. * Custom form handler.
  31. */
  32. function FORM_EXAMPLE($form, &$form_state) {
  33.  
  34. $form['complete_projects_radios'] = array(
  35. '#type' => 'radios',
  36. '#title' => t('Project status'),
  37. '#default_value' => 0,
  38. '#options' => array(0 => t('Current'), 1 => t('Complete')),
  39. // define an onChange like so:
  40. '#attributes' => array(
  41. 'onChange' => 'this.form.submit();',
  42. ),
  43. );
  44. $form['complete_projects_submit'] = array(
  45. '#type' => 'submit',
  46. '#value' => t('Apply'),
  47. // the submit itself is necessary, but now it can be hidden
  48. '#attributes' => array(
  49. 'style' => array('display: none;'),
  50. ),
  51. );
  52.  
  53. return $form;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement