Skip to content

Conversation

@mpcomplete
Copy link
Contributor

Callers can manually validate by calling validate(), or tell the Form to
validate on every change by setting the autovalidate parameter.

Fixes #7219

Callers can manually validate by calling validate(), or tell the Form to
validate on every change by setting the `autovalidate` parameter.

Fixes #7219
Form({
Key key,
@required this.child,
this.autovalidate: false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be autoValidate

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought so too, but grepping through the codebase, I found autofocus and autorefresh. There are no autoFoos anywhere. WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was originally going to say that we should call this autoValidate for consistency with Flutter names in general, but if there's an established autopattern, then I guess we should stick with it.

}
return false;
/// Validates every [FormField] that is a descendant of this [Form], and
/// returns true iff there are no errors.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"if"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"iff" means if and only if, but if that's not widely known I can change it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have complete documentation, which means that if there was any other reason for it to return true, the paragraph would mention it. So the "and only if" is implied.

@Hixie
Copy link
Contributor

Hixie commented Dec 16, 2016

LGTM

void _handleSubmitted() {
FormState form = _formKey.currentState;
if (form.hasErrors) {
_autovalidate = true; // Start validating on every change.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this code may serve as a cut-and-pasteable example maybe it would be better to only set _autovalidate true in the !form.validate() clause.

}

/// Saves every FormField that is a descendant of this Form.
/// Saves every [FormField] that is a descendant of this [Form].
Copy link
Contributor

@HansMuller HansMuller Dec 16, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[this is just a nit] I don't think you really mean descendant here? If the Form contained other forms as well as fields, you're not going to recursively find all the fields, right? It looks like the term "descendant" is used in several places where you mean "child".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean "descendant that is not a descendant of a deeper Form" but that's a mouthful. FormFields will register themselves with the closest ancestor Form.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose it will not confuse anyone. You could say "immediate descendant", or "FormFields registered with this form" but it was only a nit.

LGTM too.

@mpcomplete mpcomplete merged commit 6d4191e into flutter:master Dec 16, 2016
@mpcomplete mpcomplete deleted the form.validate branch December 16, 2016 23:14
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gallery: don't show red error messages in Input demo on initial load

4 participants