**The goal:** 

I want on a Symfony FORM to have **two submit buttons**. 1st one would be used to validate the form, the **2nd submit button would be used to get away from the form**.

By default the fields of the form use the `required` check before submitting, which means that prior to use the 2nd Submit, the `required` attributes need to be turned off on DOM `<input>`. I do that by using some JQuery, `event.preventDefault()`, I turn off the `required` on each `<input>` and then do an `event.target.submit()`.

Then on my Symfony side I expect to catch the button that had been clicked by using the `$form->has([button name])->isClicked()` function.

**The issue:**

I have noticed that depending on the browser, the $form->has([button name])->isClicked() doesn't work if some JavaScript with `event.preventDefault()` and `event.target.submit()` had been used.

On chrome (Version 51.0.2704.103 m) I get (isClicked = 1 or true):
[![enter image description here](https://i.stack.imgur.com/Vh6Z8.jpg)](https://i.stack.imgur.com/Vh6Z8.jpg)

On firefox (Version 47.0) or Microsoft EDGE 25.\* I get (isClicked = false):
[![enter image description here](https://i.stack.imgur.com/SakZe.jpg)](https://i.stack.imgur.com/SakZe.jpg)

**The code:**

[**The full code is at the following github**](https://github.com/nyluje/symfony_form_test_isclicked).

*Emphasis on the code:*

In /src/AppBundle/Form/FormType.php you'll find, the code that manages the JavaScript to hold on the `Submit`, turnoff the `required` and resume the `Submit`:

```
  public function buildForm(FormBuilderInterface $builder, array $options)
  {

    $builder
    ->add('field1',EmailType::class, array('label'=>'Form Field 1'))
    ->add('submit',SubmitType::class,array('label'=>'Submit Form'))
  ->add('get_away_from_form',SubmitType::class,array(
    'label'=>'Get away from form',
    'attr'=>array(
    'onclick'=>'{
      //IF THE USER CLICK THE NOT_SUBMIT BUTTON THE REQUIRED FIELD ARE DISABLED BEFORE THE SUBMIT HAPPENS
     // Here is the part where are done (see GITHUB code for details): 
     ////`event.preventDefault()`,
     //// turn off the `required` on each `<input>`
     //// and then do an `event.target.submit()`.

    }'
    )
    ));
  }

```

In /src/AppBundle/Controller/DefaultController.php you'll find, the check on $form->get('get\_away\_from\_form')->isClicked():

```
    if($form->isSubmitted() && $form->has('get_away_from_form')){
        if($form->get('get_away_from_form')->isClicked() == 1){
            $isClicked = 'It works as expected: $form->get(get_away_from_form)->isClicked() = '.$form->get('get_away_from_form')->isClicked();
        } else {
            $isClicked = 'It DOESN\'T work as expected: $form->get(get_away_from_form)->isClicked() = '.$form->get('get_away_from_form')->isClicked();
        }
    }

```

Anyone has an idea?