-
-
Notifications
You must be signed in to change notification settings - Fork 128
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
Custom element that holds the validation controller instance? #542
Comments
@jasonhjohnson nice Q. The scope of a <app-form validate.bind="true">
<app-form-group>
<app-label slot="label">First Name</app-label>
<app-input slot="input" type="text" value.bind="model.firstName"></app-input>
</app-form-group>
</app-form> will be different with the scope of a At the moment, we don't support this, but probably there's a way to do it, via a template controller custom attribute with a @jods4 requested this feature, in the name of template controller custom element, maybe he can chime in. |
It's possible, that's more or less how I do it in my projects. It's based on two custom elements, <data-form entity.bind='model' validation.bind='rules' with.bind='model'>
<data-field label='First name'>
<input value.bind='firstName' />
</data-field>
<data-field label='Last name'>
<input value.bind='lastName' />
</data-field>
</data-form> Those elements do a fair bit of presentation work (e.g. creating a localized label that is automatically associated with the inner control, doing the layout, etc.) but that's beside the point. The first trick is that From here, There's one trick, which is that the Sorry I don't have access to the source code right now, and that was the most tricky part. You could also try to solve that problem by having |
@jods4 Super insightful, thanks! |
Is it possible to create an "
app-form
" custom element that contains the validation controller instance and handles the validation so parent components can use it without knowing about validation?I'm considering something like:
parent.vm.html
input.element.html
sample.model.ts
The text was updated successfully, but these errors were encountered: