multiple submit buttons and confirmation dialogue on one of them
Notice: This thread is very old.
- HosipLan
- Moderator | 4668
That is a client side problem, isn't it? You can define in form definition
$input->controlPrototype
->onsubmit = "return confirm('ORLY?');";
Or better, you can put it where it belongs, but you would have to render form manualy.
...
<tr><td>{input onsubmit => "return confirm('ORLY?');"}</td></tr>
...
- richard
- Member | 60
OK. This works a bit:
<?php
$form->addSubmit('submit1')->controlPrototype->onClick("window.check = false;");
$form->addSubmit('submit2')->controlPrototype->onClick("window.check = true;");
<script>
Nette.addEvent(document.getElementById('frm-form), 'submit', function() {
if(window.check) {
if(!confirm("Sure?")) {
return false;
}
}
});
</script>
But how to do that only if form validation is OK?
?>
Last edited by richard (2011-09-26 17:30)
- HosipLan
- Moderator | 4668
If you wanna add an event on form, you can
$form->elementPrototype
->onsubmit = "if(window.check) {return confirm('ORLY?');}";
But there is already an event added to form using Unobtrusive JavaScript, so I'm not sure how it will behave.