Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

feat(form): add parent parameter #6095

Closed
wants to merge 1 commit into from
Closed

feat(form): add parent parameter #6095

wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented Feb 3, 2014

Makes it possible to:

  • disable the registration of a form in its parent form by specifying an empty or falsy value (preventing the propagation of validation, dirtiness and so on)
  • specify a custom parent form (that is not necessarily the parent in the DOM) via an Angular expression that is evaluated in the current scope

If the parameter is not specified, the form directive will traverse up the DOM to locate a parent form as before this change, so current implementations will not break. This fixes issue #5858.

Makes it possible to:
- disable the registration of a form in its parent form by specifying an empty or falsy value (preventing the propagation of validation, dirtiness and so on)
- specify a custom parent form (that is not necessarily the parent in the DOM) via an Angular expression that is evaluated in the current scope

If the parameter is not specified, the form directive will traverse up the DOM to locate a parent form as before this change, so current implementations will not break.
@ghost
Copy link
Author

ghost commented Feb 3, 2014

A known problem with this commit at the moment is that specifying a custom parent form does not work if the form is not available yet (e.g., if the referenced form is located later in the DOM than the form that references it). Not sure how to deal with this yet, or if using scope.$eval() is the best approach for this. Definitely could use some input.

@mary-poppins
Copy link

I'm sorry, but I wasn't able to verify your Contributor License Agreement (CLA) signature. CLA signature is required for any code contributions to AngularJS.

Please sign our CLA and ensure that the CLA signature email address and the email address in this PR's commits match.

If you signed the CLA as a corporation, please let us know the company's name.

Thanks a bunch!

PS: If you signed the CLA in the past then most likely the email addresses don't match. Please sign the CLA again or update the email address in the commit of this PR.
PS2: If you are a Googler, please sign the CLA as well to simplify the CLA verification process.

@MikeMcElroy
Copy link
Contributor

Specifying a non-DOM-parent parent seems very unusual to me... What circumstances make that necessary?

@mary-poppins
Copy link

CLA signature verified! Thank you!

Someone from the team will now triage your PR and it will be processed based on the determined priority (doc updates and fixes with tests are prioritized over other changes).

@ghost
Copy link
Author

ghost commented Feb 4, 2014

@MikeMcElroy I think the use cases for this feature will have very practical reasons behind them. In my case, where I would set the parent as empty, it's custom date pickers and color pickers that have their own mini form and should not propagate their $dirty state to the parent form. They are nested in the main form because they have separate instances for every field that uses a picker, and because it's easy to do the positioning with CSS this way. It works the other way around as well, someone may have a form that needs to propagate its dirtiness or validity to another, without it being a parent element in the DOM. parent might in that case not be the best name for it though, but I can't think of something better at this moment.

@ghost
Copy link
Author

ghost commented Feb 4, 2014

Btw, I'm also OK with the original solution proposed in #5858 where we would just have an attribute that says "don't propagate anything to the parent form", if the concept of setting a custom parent is too confusing or unnecessary. Let's hear some opinions.

@mary-poppins
Copy link

CLA signature verified! Thank you!

Someone from the team will now triage your PR and it will be processed based on the determined priority (doc updates and fixes with tests are prioritized over other changes).

@plentz
Copy link
Contributor

plentz commented May 28, 2014

related #5037

@ruifortes
Copy link

👍

@Narretz
Copy link
Contributor

Narretz commented Jun 7, 2016

This is worked on in a more comprehensive fashion here: #10193

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants