Drupal 7 ajax form validation and submit
Ajax is one of the best interactive way to validate and submit Drupal custom form.
Using below steps, we can achieve ajax form validation and submit.
Steps :
1) Declare form elements
2) Call back definitions.
1) Declare form elements.
01 $form['submit'] = array(
02 '#type' => 'submit',
03 '#value' => t('SUBMIT'),
04 '#validate' => array('validate_callback'), // custom form validate.
05 '#ajax' => array(
06 'callback' => 'submit_callback',
07 'effect' => 'fade',
08 'wrapper' => 'specific-wrapper',
09 'event' => 'click',
10 'progress' => array('message' => '', 'type' => 'throbber'),
11 ),
12 );
2) Call back definitions.
1 function submit_callback($form, $form_state) {
2 if (form_get_errors()) {
3 $form_state['rebuild'] = TRUE;
4 return $form;
5 }
6
7 $response = my_form_submit($form, $form_state); // write your form submit logic here.
8 return $response;
9 }
"validate_callback" is our normal hook_form_validate().
- See more at: http://kali-dasan.blogspot.in/2014/07/drupal-7-ajax-form-validation-and-submit.html#sthash.9wFmbiMI.dpuf
- See more at: http://kali-dasan.blogspot.in/2014/07/drupal-7-ajax-form-validation-and-submit.html#sthash.9wFmbiMI.dpuf
- See more at: http://kali-dasan.blogspot.in/2014/07/drupal-7-ajax-form-validation-and-submit.html#sthash.9wFmbiMI.dpuf
- See more at: http://kali-dasan.blogspot.in/2014/07/drupal-7-ajax-form-validation-and-submit.html#sthash.9wFmbiMI.dpuf
- See more at: http://kali-dasan.blogspot.in/2014/07/drupal-7-ajax-form-validation-and-submit.html#sthash.9wFmbiMI.dpuf
Ajax is one of the best interactive way to validate and submit Drupal custom form.
Using below steps, we can achieve ajax form validation and submit.
Steps :
1) Declare form elements
2) Call back definitions.
1) Declare form elements.
01 $form['submit'] = array(
02 '#type' => 'submit',
03 '#value' => t('SUBMIT'),
04 '#validate' => array('validate_callback'), // custom form validate.
05 '#ajax' => array(
06 'callback' => 'submit_callback',
07 'effect' => 'fade',
08 'wrapper' => 'specific-wrapper',
09 'event' => 'click',
10 'progress' => array('message' => '', 'type' => 'throbber'),
11 ),
12 );
2) Call back definitions.
1 function submit_callback($form, $form_state) {
2 if (form_get_errors()) {
3 $form_state['rebuild'] = TRUE;
4 return $form;
5 }
6
7 $response = my_form_submit($form, $form_state); // write your form submit logic here.
8 return $response;
9 }
"validate_callback" is our normal hook_form_validate().
- See more at: http://kali-dasan.blogspot.in/2014/07/drupal-7-ajax-form-validation-and-submit.html#sthash.9wFmbiMI.dpuf
Drupal 7 ajax form validation and submit
Ajax is one of the best interactive way to validate and submit Drupal custom form.
Using below steps, we can achieve ajax form validation and submit.
Steps :
1) Declare form elements
2) Call back definitions.
1) Declare form elements.
2) Call back definitions.
"validate_callback" is our normal hook_form_validate().
Using below steps, we can achieve ajax form validation and submit.
Steps :
1) Declare form elements
2) Call back definitions.
1) Declare form elements.
01 | $form['submit'] = array( |
02 | '#type' => 'submit', |
03 | '#value' => t('SUBMIT'), |
04 | '#validate' => array('validate_callback'), // custom form validate. |
05 | '#ajax' => array( |
06 | 'callback' => 'submit_callback', |
07 | 'effect' => 'fade', |
08 | 'wrapper' => 'specific-wrapper', |
09 | 'event' => 'click', |
10 | 'progress' => array('message' => '', 'type' => 'throbber'), |
11 | ), |
12 | ); |
2) Call back definitions.
1 | function submit_callback($form, $form_state) { |
2 | if (form_get_errors()) { |
3 | $form_state['rebuild'] = TRUE; |
4 | return $form; |
5 | } |
6 |
7 | $response = my_form_submit($form, $form_state); // write your form submit logic here. |
8 | return $response; |
9 | } |
Drupal 7 ajax form validation and submit
Ajax is one of the best interactive way to validate and submit Drupal custom form.
Using below steps, we can achieve ajax form validation and submit.
Steps :
1) Declare form elements
2) Call back definitions.
1) Declare form elements.
2) Call back definitions.
"validate_callback" is our normal hook_form_validate().
Using below steps, we can achieve ajax form validation and submit.
Steps :
1) Declare form elements
2) Call back definitions.
1) Declare form elements.
01 | $form['submit'] = array( |
02 | '#type' => 'submit', |
03 | '#value' => t('SUBMIT'), |
04 | '#validate' => array('validate_callback'), // custom form validate. |
05 | '#ajax' => array( |
06 | 'callback' => 'submit_callback', |
07 | 'effect' => 'fade', |
08 | 'wrapper' => 'specific-wrapper', |
09 | 'event' => 'click', |
10 | 'progress' => array('message' => '', 'type' => 'throbber'), |
11 | ), |
12 | ); |
2) Call back definitions.
1 | function submit_callback($form, $form_state) { |
2 | if (form_get_errors()) { |
3 | $form_state['rebuild'] = TRUE; |
4 | return $form; |
5 | } |
6 |
7 | $response = my_form_submit($form, $form_state); // write your form submit logic here. |
8 | return $response; |
9 | } |
Drupal 7 ajax form validation and submit
Ajax is one of the best interactive way to validate and submit Drupal custom form.
Using below steps, we can achieve ajax form validation and submit.
Steps :
1) Declare form elements
2) Call back definitions.
1) Declare form elements.
2) Call back definitions.
"validate_callback" is our normal hook_form_validate().
Using below steps, we can achieve ajax form validation and submit.
Steps :
1) Declare form elements
2) Call back definitions.
1) Declare form elements.
01 | $form['submit'] = array( |
02 | '#type' => 'submit', |
03 | '#value' => t('SUBMIT'), |
04 | '#validate' => array('validate_callback'), // custom form validate. |
05 | '#ajax' => array( |
06 | 'callback' => 'submit_callback', |
07 | 'effect' => 'fade', |
08 | 'wrapper' => 'specific-wrapper', |
09 | 'event' => 'click', |
10 | 'progress' => array('message' => '', 'type' => 'throbber'), |
11 | ), |
12 | ); |
2) Call back definitions.
1 | function submit_callback($form, $form_state) { |
2 | if (form_get_errors()) { |
3 | $form_state['rebuild'] = TRUE; |
4 | return $form; |
5 | } |
6 |
7 | $response = my_form_submit($form, $form_state); // write your form submit logic here. |
8 | return $response; |
9 | } |
Drupal 7 ajax form validation and submit
Ajax is one of the best interactive way to validate and submit Drupal custom form.
Using below steps, we can achieve ajax form validation and submit.
Steps :
1) Declare form elements
2) Call back definitions.
1) Declare form elements.
2) Call back definitions.
"validate_callback" is our normal hook_form_validate().
Using below steps, we can achieve ajax form validation and submit.
Steps :
1) Declare form elements
2) Call back definitions.
1) Declare form elements.
01 | $form['submit'] = array( |
02 | '#type' => 'submit', |
03 | '#value' => t('SUBMIT'), |
04 | '#validate' => array('validate_callback'), // custom form validate. |
05 | '#ajax' => array( |
06 | 'callback' => 'submit_callback', |
07 | 'effect' => 'fade', |
08 | 'wrapper' => 'specific-wrapper', |
09 | 'event' => 'click', |
10 | 'progress' => array('message' => '', 'type' => 'throbber'), |
11 | ), |
12 | ); |
2) Call back definitions.
1 | function submit_callback($form, $form_state) { |
2 | if (form_get_errors()) { |
3 | $form_state['rebuild'] = TRUE; |
4 | return $form; |
5 | } |
6 |
7 | $response = my_form_submit($form, $form_state); // write your form submit logic here. |
8 | return $response; |
9 | } |
No comments:
Post a Comment