Skip to content
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

How to use ControlValueAccessor with Reactive forms generator? #168

Open
Dionnie123 opened this issue Jul 3, 2024 · 5 comments
Open

How to use ControlValueAccessor with Reactive forms generator? #168

Dionnie123 opened this issue Jul 3, 2024 · 5 comments

Comments

@Dionnie123
Copy link

I use freezed + reactive forms generator and I have this color picker field.

    @RfControl()
    @Default(Colors.red)
    Color colorPick,

I'm struggling to integrate the ControlValueAccessor with my form management and database saving processes. Despite using reactive_forms_generator to generate form controls, I find it challenging to exert control over how values are handled, particularly with saving data to the database.

@vasilich6107
Copy link
Contributor

Control value accessors are used to convert values from form state to control consumable format and back.
They are not for retrieving the values.

@vasilich6107
Copy link
Contributor

@vasilich6107
Copy link
Contributor

Control value accessors are used with fields, and not with generator

@Dionnie123
Copy link
Author

@vasilich6107 reactive color picker was built to accept Color type and return Color type, what approach do you recommend if I want the color field to accept Color type and return int type or vice-versa? should I make my custom color picker from scratch?

@vasilich6107
Copy link
Contributor

vasilich6107 commented Jul 10, 2024

Color could be created from int
const Color(int value)

and Colors.red.value returns int

so you can retrieve int value from color when putting the item to database using value

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

No branches or pull requests

2 participants