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

TextField readonly does not work when referencing a variable defined by a checkbox #75

Closed
Tibasa opened this issue Jun 8, 2019 · 4 comments

Comments

@Tibasa
Copy link

Tibasa commented Jun 8, 2019

TextField readonly does not work when referencing a variable defined by a checkbox.
Example:

Expanded(
  child: FormBuilderTextField(
    attribute: 'textField',
    controller: textFieldController,
    readonly: _disableTextField, // This does not work
    decoration: InputDecoration(
      labelText: _disableTextField ? 'Disabled' : 'Enabled', // This works
    ),
  )
),
Expanded(
  child: FormBuilderCheckbox(
    attribute: 'checkBox',
    initialValue: false,
    onChanged: (val) {
      setState(() {
        if (val) {
          textFieldController.clear();
          _disableTextField= true;
        } else {
          _disableTextField= false;
        }
      });
    },
  )
)

In the example above, label switching works, but deactivation of the field does not work

Need help. Thanks in advance

@dhaalves
Copy link
Contributor

Same applies for FormBuilderRadio

@dhaalves
Copy link
Contributor

dhaalves commented Jun 24, 2019

I being trying to debug the problem, and moving the line
_readonly = (_formState?.readonly == true) ? true : widget.readonly;
from method initState() to the first line of build(BuildContext context) seens to fix the issue

@danvick
Copy link
Collaborator

danvick commented Jun 25, 2019

Hi @Tibasa.
Try out version 3.2.3 of the plugin which works as expected thanks to the good work by @dhaalves

@danvick danvick closed this as completed Jun 25, 2019
@Tibasa
Copy link
Author

Tibasa commented Jul 21, 2019

Thanks very much!!!

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

3 participants