Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Nette] forms setRequired(false) #28

Merged
merged 22 commits into from
Sep 6, 2017
Merged

Conversation

TomasVotruba
Copy link
Member

@TomasVotruba TomasVotruba commented Sep 5, 2017

Closes #27

image

What is the function?

I really didn't get it from the forum, so at the moment it works like this:

Find on variable of Nette\Application\UI\Form type:

->addCondition($form::FILLED)

and replace it by:

->setRequired(false)

Could you confirm/help me with that @dg && @petrvacha?

@TomasVotruba TomasVotruba merged commit 645d92d into master Sep 6, 2017
@TomasVotruba TomasVotruba deleted the nette-forms-set-required branch September 6, 2017 22:33
@dg
Copy link

dg commented Sep 9, 2017

Just note: in specific cases, this may be an incompatible change.

@TomasVotruba
Copy link
Member Author

I don't actually understand it... this is just first example.

Could you provide cases to make it compatible?

@dg
Copy link

dg commented Sep 9, 2017

I mean rare cases. For example:

$form->addText('name')
    ->addCondition($form::FILLED)
        ->addRule(...)
        ->addRule(...);

$form['name']
        ->addRule(...); // this rule is called regardless of whether it is filled in (Nette 2.4 triggers warning here that will force you to decide whether the field is required or not)

Automatically changed code:

$form->addText('name')
    ->setRequired(false)
    ->addRule(...)
    ->addRule(...);

$form['name']
        ->addRule(...); // now is this rule called only when input is filled (no warning is triggered)

@TomasVotruba
Copy link
Member Author

Thanks. I haven't seen such use case yet.

So there should be added another refactoring, that adds setRequired() if there is only addRule()?

@dg
Copy link

dg commented Sep 9, 2017

Yes, when there is addRule(), there must be setRequired().

But every such changes must be checked by the programmer, because in some cases it can change the function.

@TomasVotruba
Copy link
Member Author

Sure, the aim is to keep programmer out of manually work and keep only checking. Something like code review.

Thanks, I will look on that later

TomasVotruba added a commit that referenced this pull request May 14, 2021
rectorphp/rector-src@15be298 [Config] update duplicate Skip fixture config (#28)
echo511 pushed a commit to echo511/rector that referenced this pull request Sep 4, 2021
* [Config] Remove duplicate Skip fixture config

* uupdate to */Fixture*/*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants