If someone can help me with an idea. I have a second button on my webform with an specific handler. Everything it's OK it execute my function but I want that this button to also save in the db of drupal like the first button. But only the first button do that. I don't understand why. I must to set something special in the definition of this button to do that?

Here is how I created my buttons:

array_unshift($form['#submit'], 'decla_form_submit');

if ($declaLineOrigin[0] -> CLOSED == 'N') {
    $form['actions']['submit'] = array(
        '#type' => 'submit',
        '#value' => t('Recalculer'),
        '#validate' => array('decla_validate'),
        '#prefix' => '<div id="replace_decla_button_div">',
        '#weight' => 50,

    $form['actions']['validation'] = array(
        '#type' => 'submit',
        '#value' => t('Valider'),
        '#submit' => array('decla_form_validation_submit'),
        '#executes_submit_callback' => TRUE,
        '#suffix' => '</div>',
        '#weight' => 70,

Is the "Valider" button. The div is for an ajax call ... I want to hide this button if an specify textfield change.

$form['submitted']['declaration_fieldset']['base_trimestre']['#ajax'] = array(
    'callback' => 'decla_fire_callback',
    'wrapper' => array('replace_decla_button_div'),
    'event' => 'click',
    // 'event' => 'input',
    'progress' => 'none',

Thank you everyone and have nice day !

  • I don't understand your question: when you click "Valider" button, the function decla_form_validation_submit is not called? And this is the problem? – user4035 Jun 27 '14 at 8:36
  • Also you said, that you want to hide "Valider" button, when something is changed in a textfield. What textfield? I don't see anything about that in the code. Anyway, it can be easily done via javascript. – user4035 Jun 27 '14 at 8:37
  • Thank you. decla_form_validation_submit is called and it's works fine. But the form it's not saved in the drupal db like when you click on submit. You can't see the results in results area of webform. I need this to fill a pdf whith fillpdf. – user33550 Jun 27 '14 at 9:09
  • To hide the button I use an ajax on my textfield and it's work. The only problem is that I set the event on my ajax to 'click' and it's called every time when you click on the textfield. It was much better to do that using un event like 'change' but I don't now how to set up un delay, because ajax it's fired every time you change samething. Normaly you must to have an delay after you changed the value and the ajax is fired. If you have an ideea .... :) – user33550 Jun 27 '14 at 9:14
  • Maybe, for the textfield, you can use onBlur event, that fires, when the cursor leaves the text input? In that function you'll need to check, whether the user changed something. – user4035 Jun 27 '14 at 9:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.