grav-plugin-form
grav-plugin-form copied to clipboard
Can't update Flex User field from empty textarea
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:

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?
What I see using Xdebug on User save in Admin panel (parseRequest func):

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