Permalink
Browse files

Forms: added example of isSubmittedBy and isSubmitted [#720] (#726)

  • Loading branch information...
f3l1x authored and dg committed Oct 3, 2018
1 parent d3d6ece commit cda6053c914b804744f01fbee951ebe014cc7455
Showing with 30 additions and 0 deletions.
  1. +15 −0 cs/form-fields.texy
  2. +15 −0 en/form-fields.texy
@@ -215,6 +215,21 @@ Přidá odesílací tlačítko (třída [SubmitButton |api:Nette\Forms\Controls\
$form->addSubmit('submit', 'Odeslat');
\--

Je v pořádku přidat více než jedno odesílací tlačítko.

/--php
$form->addSubmit('submit', 'Register');
$form->addSubmit('cancel', 'Cancel');
\--

Ke zjištění, na který z nich bylo kliknuto, použijte:

/--php
if ($form['submit']->isSubmittedBy()) {
// ...
}
\--

Pokud nechcete validovat formulář při stisknutí tlačítka (například u tlačítek *Zrušit* nebo *Náhled*), můžete ji vypnout pomocí `setValidationScope([])`.


@@ -215,6 +215,21 @@ Adds submit button (class [SubmitButton |api:Nette\Forms\Controls\SubmitButton])
$form->addSubmit('submit', 'Register');
\--

It's okay to add more than one submit button.

/--php
$form->addSubmit('submit', 'Register');
$form->addSubmit('cancel', 'Cancel');
\--

To find out which of them was clicked, use:

/--php
if ($form['submit']->isSubmittedBy()) {
// ...
}
\--

If you don't want to validate the form when a submit button is pressed (such as *Cancel* or *Preview* buttons), you can turn it off with `setValidationScope([])`.


0 comments on commit cda6053

Please sign in to comment.