forms icon indicating copy to clipboard operation
forms copied to clipboard

Enable/Disable the field from the formField

Open donpaul120 opened this issue 3 years ago • 6 comments

Would be nice if i could disable or enable the formField directly from the FormField

donpaul120 avatar Sep 05 '22 00:09 donpaul120

If you mean to enable/disable validation for a formField, yea would be nice. For now, you could work around it by adding/removing the form field from the form, and then enabling/disabling the UI element.

You are also welcome to send a PR!

nwagu avatar Sep 05 '22 11:09 nwagu

No i mean, being able to directly disable the formField which also disables the view form being able to get edited... let me know what you think about that.

donpaul120 avatar Sep 05 '22 12:09 donpaul120

The formfields are meant to be part of the ViewModel, decoupled from the UI. So no, it can't do that sorry

nwagu avatar Sep 05 '22 12:09 nwagu

No, you don't seem to understand, i'm not asking that the view coupled with the formField. it's the same way we have error(live-data) etc, we should be able to provide events for other states.

such that within the viewModel i can control the logic of disabling the formField or enabling it, like you said it's meant to be part of the viewmodel.

However the workaround is to provide a boolean field in the viewModel and bind that to the view.

donpaul120 avatar Sep 05 '22 12:09 donpaul120

Ok, I understand now and it makes sense. But not sure how soon I can work on it. I would appreciate a pull request if you ever work on it.

I think that with all these states that need to be observed, we can have one generic callback with a tag parameter: enable, disable, requestfocus, etc, at the point of emitting so it is more flexible. Error and feedback can remain separate (or not).

nwagu avatar Sep 05 '22 13:09 nwagu

Perfect! makes sense!... I'll see how to work on it and send a PR...

donpaul120 avatar Sep 05 '22 13:09 donpaul120