In this provided example of a phone number: creating-a-custom-form-field-control
There is a few things that are lacking:
maxlength="3"Adding some additions to what @tmburnell has already stated:
The example is also missing the key components of how to actually implement this with formControl and ngControl which is the whole basis of using forms in Angular. I feel that this is a very important component of building custom form fields and should be include in the guide. As for the StackBlitz demo whenever I try to load the page I get the "Starting Dev Server" loading screen and it never moves passed it.
I was able to create a custom mat-form-field which implements MatFormFieldControl, I was also able to make it work with formControl however whenever the field is invalid, the color of the entire mat-form-field does not change as a normal mat-form-field, it should turn to red but it's not, because the class mat-form-field-invalid is not being added.
Can we get someone to look at this? it appears that there is a need for being able to create custom form components, but it is entirely unclear as to how to get validation, value passing and error highlighting working... also see https://github.com/angular/material2/issues/13624
@tmburnell this might help you (auto-advance):
https://medium.com/@wildhammer/angular-material-phone-input-2283c7bc3372
I will submit a pull request for this
@mmalerba how is material.angular.io updated? I still don't see these changes I made under the guide for a custom field on the website.
@Wildhammer The only thing i see that your doc updates did not cover was being able to clear the whole field at once.
you have to tab into each our start at the end and hit delete 10 times
That wouldn't be possible with this way of implementation (using three separate fields). For that, you need only one input that styles the text while typing (adding dashes or paran for the area code).
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
_This action has been performed automatically by a bot._
Most helpful comment
Can we get someone to look at this? it appears that there is a need for being able to create custom form components, but it is entirely unclear as to how to get validation, value passing and error highlighting working... also see https://github.com/angular/material2/issues/13624