-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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
two-way data binded FormControl does not update form valid status #18582
Comments
|
@Toxicable Still reproducible.. What was your change? |
You were using the Forms incorrectly |
fixed: https://plnkr.co/edit/aahDvprAe7y6Fh7koeu2?p=preview @Toxicable you probably forgot to save plunker? @emreavsar why do you want to create intermediate form group? Date control worked directly with it, instead of most parent. |
@tytskyi whops, yeah I did, mine is the same as yours though so we'll go with that |
Ok but now you removed the formcontrol from the date.component and put it into the parent component. This breaks somehow the self-contained functionality. One can imagine that the date.component has its own validation rules and should be a drop-in usable component. with the provided plunkr of @tytskyi this 'self-containment' gets lost. That was the main idea of using the |
@emreavsar what exactly you are trying to achieve? Do you want your
note that i did not "put" it to the parent component, it was already there. |
@tytskyi i want to have a the main idea of the sorry that was my mistake, it was already there as you said. So are my expectations just wrong? is |
Modifying There is the working plunker made from your original one: https://plnkr.co/edit/mtYdLglU2Q1UuOM87RKf?p=preview (fixed link) But i think what you are really looking for - is to implement |
@tytskyi thanks but I think this is just not leading to the right solution as mentioned by you. So final question would be What to use (since this is not supported by angular forms) for:
I just want to use this date component like I'm using other form controls like the md-datepicker (which has similar requirements as described above). What about custom form groups? note: the initial idea of this ticket was to report a bug, which slightly turned into a CR or rather support issue. thanks anyway 👍 |
@emreavsar i considered your questions, but unfortunately i cannot answer, since i am not an advanced user of reactive forms, but i always prefer template driven forms until it's easier to use reactive. I find reactive forms too complicated for me. Also i never had such requirements as you. But if i would - i would implement component that implements But i don't think if it's good or bad solution. I think you better search in the internet something like "angular nested form group" etc. Also i suggest you to ask in https://gitter.im/angular/angular. |
@emreavsar If you want your custom form control to integrate with Angular forms, it has to implement ControlValueAccessor (as others have mentioned). If you want that integration to include validation, implement the Validator interface as well and provide your custom control as an NG_VALIDATOR. You can see an example of this in I'm closing this as a question, but worth noting that our Gitter community is pretty awesome if you have further questions about this. We should be updating form docs soon to add more information about CVAs, so hopefully that will help as well. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
I'm submitting a...
Current behavior
When having form controls in child components, and they are passed to the child component as
@Input()
and changes get retrieved with@Output()
(two way data binding) theform.valid
status gets not updated.Expected behavior
The
form.valid
status should get updated.Minimal reproduction of the problem with instructions
when you change the firstname again, the form gets re-validated. I think it's because of the
@Output()
but this should work as well in my opinion.What is the motivation / use case for changing the behavior?
Environment
The text was updated successfully, but these errors were encountered: