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

depends_on doesn't work on form fields in Fieldsets/Groups #386

Open
fredvd opened this issue Dec 6, 2022 · 9 comments
Open

depends_on doesn't work on form fields in Fieldsets/Groups #386

fredvd opened this issue Dec 6, 2022 · 9 comments

Comments

@fredvd
Copy link
Member

fredvd commented Dec 6, 2022

I have tested the new depends_on feature to use pat-depends for interactions between fields in Plone 6.0.0rc1 and collective.easyform 4.1.1

The feature works for fields in the 'main' easyform and I see the data-pat-depends attributes being set on the fields. But as soon as you move a field into a field set the attributes disappear from the form html inputs :-/ Maybe pat-depends also has issues when fields are hidden/ or in groups, but I can't check that yet.

I suspect an interface/adapter issue between normal fields and fieldset/group fields in Easyform like we've had multiple times already with the codebase, but I couldn't find the exact location we need to register/adapt.

@MrTango @petschki any idea where this could be caused and fixed?

@Nimo-19
Copy link
Contributor

Nimo-19 commented Jul 18, 2023

Hi,
I recently found a workaround, by overriding plone.app.z3cform.templates.widget.pt somewhat like this:

<div
   metal:define-macro="widget-wrapper"
   i18n:domain="plone"
   tal:define="[...];
               additional_css python: widget.field.queryTaggedValue('css_class');
               [...]
               pat_depends_class python: dependencies and 'pat-depends';
	       [...]"
   data-pat-inlinevalidation='{"type":"z3c.form"}'
   data-pat-depends="${dependencies}"
   tal:attributes="class string:field pat-inlinevalidation ${fieldname_class}${error_class}${empty_class} ${wrapper_css_class} ${additional_css} ${pat_depends_class};
                   [...]">
[...]

I dont know if this is a good approach, but it works for now.

@petschki
Copy link
Member

petschki commented Jul 18, 2023

Well this template override is exactly what easyform should do with adapters. And it already does without fieldsets though so there might be some missing logic. I recently had something similar with datagridfield and fieldsets ... need to look what I did there...

@Nimo-19
Copy link
Contributor

Nimo-19 commented Jul 24, 2023

Is it possible that the fix never made it to the plone5 compatible 3.X.X version line of collective.easyform

@petschki
Copy link
Member

pat-depends is a Patternslib pattern and is not available in Plone 5. I remember the package plone.patternslib which could be installed in Plone 5 to include some patterns, but I do not know if pat-depends is included and you have to implement the template changes for collective.easyform 3.x yourself

@Nimo-19
Copy link
Contributor

Nimo-19 commented Jul 24, 2023

The template changes for 3.x are all there. collective.easyform[patternslib] installs plone.patternslib for easyform 3.2.1.
The depends_on works on fields not within a fieldset.
Just seems to me that this fix: 3fa337b was never "back ported" to the 3.X Version

@petschki
Copy link
Member

Ah, so -> sorry for the noise ... didn't knew that. 👍🏼

Then, this commit should definitely be backported ...

@MrTango
Copy link
Contributor

MrTango commented Jul 24, 2023

@Nimo-19 would you mind backporting and testing it?
And create a new PR against 3.x

@MrTango
Copy link
Contributor

MrTango commented Jul 24, 2023

or @fredvd ?

@fredvd
Copy link
Member Author

fredvd commented Jul 24, 2023

I’m on vacation this week. I remember making an interim release earlier this year to get the on_depends to work properly, but that was already for a Plone 6.0 site. Not sure if thar also was a fieldset issue, but I think so. I can look at it when I’m back.

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

4 participants