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 type model/change binding #3572
Comments
I think I figured it out actually. Some important first timer notes especially those using PrimeNG:
Formly is amazing in how almost everything is completely automated. However, it took me some time to figure out how all of this was working. I guess it was good in case some new user wants more information, or a quicker start than I had this weekend. So what does a color type with picker look like? import {Component} from '@angular/core';
import {FieldType, FieldTypeConfig} from '@ngx-formly/core';
@Component({
selector: 'formly-color-type',
template: `
<div class="mb-3">
Model Value: {{field.model?.mycolor}}
<p-colorPicker [formlyAttributes]="field" [formControl]="formControl"></p-colorPicker>
</div>
`,
})
export class ColorTypeComponent extends FieldType<FieldTypeConfig>{} It ends up being so much easier than you would even think, once you get past the |
i have this issues when trying to implements multiple formcontrol in 1 field, the model just wont update whenever the fields change. I thinks it works fine in version 5.0.0 but in 6.1.1 it doesnt works anymore since I followed the first implementation #1222. Here is my implementation for 6.1.1, if you can give it a look and address the issue i am really thankful: https://stackblitz.com/edit/angular-ivy-rabcxg?file=src/app/app.component.html |
This issue has been fixed and released as part of v6.2.1 release. Please let us know, in case you are still encountering a similar issue/problem. |
I need some direction. I like the docs I have seen. However, I am looking to create custom field types. I am trying to understand from existing implementations how model/change binding/propagation works. I do not see any details at this level anywhere in the docs.
For example, as I am new, I have taking the jsonschema advanced example as a starting point. I wanted to try to create a color picker(I have seen other examples, but I am trying to learn instead of copy). I am using PrimeNG components, so naturally using
p-colorpicker
. There is a 2-way binding for the color to that component by default. From the implementations I see, and from trying it, 2-way binding is not allowed. The model is read-only. So naturally, you just use input binding on the model value (existing value), and then you implement the(onChange)
emitter. However, then how to update the model from that function?The model is read only. I have seen other examples in the existing implementations like:
However, this has no impact. Are there docs on how to implement? Specifically, that tell me how this all works and what it means to change the model and its binding? I saw in the docs where it says what it is based on. Should I read through those docs first?
I don't want to ask silly questions, but I feel like I am spinning my wheels a bit and am digging into the codebase, hopefully not over doing it, and it appears there are some really great devs that use this project heavily from the issues list. Hoping I can get a helping hand, to give me a better direction to start from. Thanks again in advance! Excellent project!
The text was updated successfully, but these errors were encountered: