D
D
Dmitry Kamyannoy2014-12-08 17:37:53
PHP
Dmitry Kamyannoy, 2014-12-08 17:37:53

How to add ajax to page break (webform ) Drupal button?

Good evening, please help me to add ajax handler to the button.
I'm making a form in a modal window, I attached a handler to the "Finish" button. And here is the page break button. Well, no way. It's just a nightmare. The thing is that without a handler, the form collapses, but I don't need it. That's all I have. trebuemye_dokumenty
brRDaJESYeEn21.jpg
field key Module code for the "checkout" button


function pixelbroks_form_alter(&$form, &$form_state, $form_id) {
// do ajax submit generic for all the webform those have no redirect option enabled.
if($form['#node']->webform['redirect_url'] == "<none>"){
$matches = array();
//check whether the form id have nid at the end like _nid
preg_match('/[\d]+$/', $form_id, $matches);
$nid_match = $matches[0];
if(strpos($form_id, 'webform_client_form_') == 0 && !empty($nid_match)){
$form['actions']['submit'] = array(
'#type' => 'submit',
'#ajax' => array(
'callback' => 'webform_client_form_ajax_callback',
'wrapper' => str_replace('_','-',$form['#form_id']),
'effect' => 'fade',
),
'#value' => t('Оформить'),
);

}
}
}
 
function webform_client_form_ajax_callback($form, &$form_state) {
if(form_get_errors()){
return $form;
}
else{
return $form['#node']->webform['confirmation'];
}
}

Thank you very much

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question