nette / forms

📝 Generating, validating and processing secure forms in PHP. Handy API, fully customizable, server & client side validation and mature design.

Home Page:https://doc.nette.org/forms

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Implementation of setOmitted() to Nette\Forms\Rules

fixsoftware opened this issue · comments

Currently, there is no option to use setOmitted() in conditions.

This implementation:

$form->addText('firstname', 'locale.checkout.form.firstname.headline')
    ->setDefaultValue($this->getDefaultProfileData('billing_firstname'))
    ->setMaxLength(128)
    ->addRule($form::MAX_LENGTH, 'locale.checkout.form.firstname.max_length', 128)
    ->addConditionOn($form['billing_enabled'], $form::FILLED)
        ->setRequired('locale.checkout.form.firstname.required')
    ->elseCondition()
        ->setOmitted() // if section is not enabled, do not save data
    ->endCondition();

Results in:

Call to undefined method Nette\Forms\Rules::setOmitted().

I don't plan on adding this.