$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
'#attributes' => array(
'onclick' => 'javascript:var s=this;setTimeout(function(){s.value="Saving...";s.disabled=true;},1);',
),
);
drupal7
Monday, 29 December 2014
How can I disable a Drupal form submit button when it is clicked to prevent double submission?
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;}'),
);
Thursday, 27 November 2014
OR condtion in drupal 7
That's not correct, the default is AND. To use or, you need to use:
$or = db_or();
$or->condition();
$or->condition();
$query->condition($or);
Saturday, 1 November 2014
Upload images in drupal 7
$form ['boxthird'] ['thirdcontentlogo'] = array (
'#type' => 'managed_file',
'#prefix' => '<div class = "row-fluid">',
'#suffix' => '</div>',
'#description' => '<p style="font-size:12px"><span class="icon-hand-right"> </span> Uploaded Inner logo Image Size should be 165 x 61 pixels. </p></span>',
'#upload_location' => 'public://sitefiles/',
'#default_value' => isset ( $gethomestaticdata ['boxthird'] ['thirdcontentlogo'] ) ? $gethomestaticdata ['boxthird'] ['thirdcontentlogo'] : ''
);
if ($form_state ['values'] ['kitphotos'] != "") {
$validators = array ();
$dest = file_default_scheme () . '://sitefiles/';
$file = file_save_upload ( 'slider_image', $validators, $dest );
if (is_null ( $file )) {
$file = file_load ( $form_state ['values'] ['kitphotos'] );
$file->status = "1";
$fileobject = file_save ( $file );
$buffet_img_fid = $fileobject->fid;
// file usuage
$fileusuage = new stdClass ();
$fileusuage->fid = $fileobject->fid;
file_usage_add ( $fileusuage, 'file', 'mediakit', '111' );
} else {
$file->status = "1";
$fileobject = file_save ( $file );
$buffet_img_fid = $fileobject->fid;
// file usuage
$fileusuage = new stdClass ();
$fileusuage->fid = $fileobject->fid;
file_usage_add ( $fileusuage, 'file', 'mediakit', '111' );
}
}
Friday, 31 October 2014
add class to drupal 7
$form['myboxes']['foo'] = array(
'#attributes' => array('class' => array('ok')),
);
'#attributes' => array('class' => array('ok')),
);
Thursday, 30 October 2014
Active search get rebuild the form using drupal 7 seach
function specialoffers_manage_validate($form, &$form_state) {
drupal_set_title('Special Offers');
drupal_add_css(drupal_get_path('module', 'specialoffers') .'/css/specialoffers.css');
$acitiveinactive = '';
$form['#method'] = 'post';
$acitiveinactive = isset($_POST['filterset']['filteroptions']) ? $_POST['filterset']['filteroptions'] : 1;
if(($acitiveinactive == '1') || ($acitiveinactive == '0') ){
$offerstatusresult = new offersoverview();
$offerstatusresult->status = $acitiveinactive;
$result = $offerstatusresult->getoffersOrderbyPosition();
} else{
$offersall = new offersoverview();
$offersall->status = $acitiveinactive;
$result = $offersall->getoffersAll();
}
global $base_url;
$form['filterset'] = array(
'#type' => 'fieldset',
'#prefix' => '<div class="fleetviewcontain">',
);
$form['filterset']['filteroptions'] = array(
'#id' => 'filteroptions',
'#type' => 'select',
'#options' => array( 'All' => 'All' ,'1'=>'Active','0'=>'Inactive'),
"#limit_validation_errors" => array(),
'#default_value' => $acitiveinactive,
);
$form['filterset']['btn'] = array(
'#type' => 'submit',
'#value' => 'Go',
);
function specialoffers_manage_validate($form, &$form_state) {
if ($form_state['triggering_element']['#value'] == 'Go') {
$form_state['rebuild'] = TRUE;
return;
}
}
Subscribe to:
Comments (Atom)