CluesShop.com

Monday, 29 December 2014

How can I disable a Drupal form submit button when it is clicked to prevent double submission?

$form['submit'] = array(
  '#type' => 'submit',
  '#value' => t('Save'),
  '#attributes' => array(
    'onclick' => 'javascript:var s=this;setTimeout(function(){s.value="Saving...";s.disabled=true;},1);',
  ),
);

Monday, 22 December 2014

Multipel status change for drupal 7


 multiple status for drupal 7 change

  $form['name'] = array(
            '#type' => 'textfield',
            '#title' => t(''),
            '#description' => '',
            '#default_value' => isset($name) ? $name : '',
            '#attributes' => array('placeholder' => array('Search')),
            '#prefix' => '<div class="span3 custom-nomargin">',
            '#suffix' => '</div>',
            '#states' => array(
            'visible' => array(
                        '#agent_order' => array(
                            array('value' => 'OrderID'),
                            array('value' => 'Event Name')
                        ),
             ),
        ),

single status for drupal 7 change

  $form['name'] = array(
        '#id' => 'name',
        '#type' => 'textfield',
        '#title' => t(''),
        '#description' => '',
        '#default_value' => isset($name) ? $name : '',
        '#attributes' => array('placeholder' => array('Search')),
        '#states' => array(
            'invisible' => array('#status' => array('value' => 'ALL'),
            ),
        ),
        '#prefix' => '<div class="span3 custom-nomargin">',
        '#suffix' => '</div>',
    );

Wednesday, 3 December 2014

Confirmation Dialog box for Delete or not in druapl 7

$form['delete'] = array(
    '#type' => 'submit',
    '#value' => t('Delete'),
    '#attributes' => array('onclick' => 'if(!confirm("Really Delete?")){return false;}'),
);