Form consisting only from checkbox

Notice: This thread is very old.
h4kuna
Backer | 740
+
0
-

Hi, i create checkbox-list send via javascript and if checkboxes are FALSE and one is TRUE then form doesn't execute callback onSuccess. I can't remove last value from database.

Use case:

// presenter
public function createComponentForm() {
    $form = new Nette\Application\UI\Form;
    $form->addCheckbox('test', 'Ano?')->setValue(1);
    $form->onSuccess[] = callback($this, 'form');
    return $form;
}

public function form(Nette\Application\UI\Form $form) {
    dump($form->getValues());
    exit;
}
{control form}
<script>
    $(document).ready(function ($) {
        $('#frmform-test').change(function(){
            $(this).closest('form').submit();
        });
    });
</script>

If you click to checkbox dump won't execute.

But I find hack, whose look like:

public function createComponentForm() {
    $form = new Nette\Application\UI\Form;
    $form->addCheckbox('test', 'Ano?')->setValue(1);
    $form->onSuccess[] = callback($this, 'form');
    $form->addHidden('hack', 1);
    return $form;
}

EDIT

Nette 2.0.10

PHP 5.3.10

Last edited by h4kuna (2013-04-05 22:17)

petr.pavel
Member | 533
+
0
-

Would it help, as a workaround, to add a dummy hidden field?