Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //form hook, form elements start here
- function form_casl_form($form, &$form_state) {
- //sometext here
- $form['some_text'] = array(
- '#markup' => '<p><b>Simply click the button to subscribe.</b>
- </p>'
- );
- //submit button
- $form['submit_button'] = array(
- '#type' => 'submit',
- '#value' => t('Subscribe'),
- );
- return $form;
- }
- //validate hook
- $form['#attached']['js'][] = drupal_get_path('module', 'YOURMODULE') . '/YOURMODULE.js';
- Drupal.behaviors.YOURMODULE = {
- attach: function(context, settings) {
- $('.your-form-selector', context).once('YOURMODULE').delay(10000).submit();
- }
- }
- /**
- * Custom form handler.
- */
- function FORM_EXAMPLE($form, &$form_state) {
- $form['complete_projects_radios'] = array(
- '#type' => 'radios',
- '#title' => t('Project status'),
- '#default_value' => 0,
- '#options' => array(0 => t('Current'), 1 => t('Complete')),
- // define an onChange like so:
- '#attributes' => array(
- 'onChange' => 'this.form.submit();',
- ),
- );
- $form['complete_projects_submit'] = array(
- '#type' => 'submit',
- '#value' => t('Apply'),
- // the submit itself is necessary, but now it can be hidden
- '#attributes' => array(
- 'style' => array('display: none;'),
- ),
- );
- return $form;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement