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

Can't update Flex User field from empty textarea #586

Open
Sogl opened this issue Dec 23, 2022 · 1 comment
Open

Can't update Flex User field from empty textarea #586

Sogl opened this issue Dec 23, 2022 · 1 comment

Comments

@Sogl
Copy link
Contributor

Sogl commented Dec 23, 2022

I have some options:

  • Account Type: Flex Objects (experimental) for Users.
  • Session split false, one session for admin and frontend.
  • Sync User in Session enabled (Login plugin).

I have some additional fields in my user\blueprints\user\account.yaml:

...
specialist:
    type: toggle
    label: PLUGIN_SOGLFLEX.ADMIN.USER.SPECIALIST
    highlight: 1
    default: 0
    options:
        1: PLUGIN_ADMIN.YES
        0: PLUGIN_ADMIN.NO
    validate:
        type: bool
        required: true

about_specialist:
    type: editor
    size: large
    label: PLUGIN_SOGLFLEX.ADMIN.USER.ABOUT_SPECIALIST
    placeholder: PLUGIN_SOGLFLEX.ADMIN.USER.ABOUT_SPECIALIST_PLACEHOLDER
...

These fields added to Login plugin registration fields:
image

I have user\pages\profile\profile.md for custom User profile frontend form. I added two fields:

...
specialist:
    type: toggle
    options:
        1: PLUGIN_ADMIN.YES
        0: PLUGIN_ADMIN.NO
    
specialist_check:
    type: conditional
    condition: "form.value('specialist') == true"
    fields:
        about_specialist:
            type: textarea
            label: PLUGIN_SOGLFLEX.ADMIN.USER.ABOUT_SPECIALIST
            placeholder: PLUGIN_SOGLFLEX.ADMIN.USER.ABOUT_SPECIALIST_PLACEHOLDER
            classes: input-lg
            rows: 7
...

And now the description of the problem. When I clear the about_specialist field from the Admin panel, it disappears in user.yaml file, it's fine. But I can't do this in frontend profile form, every form submit or refresh shows me initial textarea value. It's updated only if a value is specified in it, even a simple space.

Also, if I clear textarea in the Admin panel, the old value is still indicated when entering the frontend profile. It appears on every form refresh. Only the user's logout/login can clear this value (is it because the session is being recreated?).

I can't clear textarea value in frontend form. How to fix that?

@Sogl
Copy link
Contributor Author

Sogl commented Dec 23, 2022

What I see using Xdebug on User save in Admin panel (parseRequest func):
image

Empty textarea parses as empty string. In frontend form it's about_specialist: null which is not included in the final request.

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

1 participant