collective / collective.easyform

Forms for Plone
https://pypi.org/project/collective.easyform
13 stars 28 forks source link

depends_on not working in easyform 3.2.0 and plone 5.2 #380

Open Nimo-19 opened 1 year ago

Nimo-19 commented 1 year ago

I just saw the depends_on feature and was exited, but somehow I cant get it to work with easyform 3.2.0. Is there some other dependency?

The form view page does not seem to do anything with this feature.

My barebones buildout

[buildout]
extends =
    http://dist.plone.org/release/5-latest/versions.cfg

parts =
    instance

versions = versions

[instance]
recipe = plone.recipe.zope2instance
user = admin:admin
http-address = 8080
eggs =
    Plone
    collective.easyform

[versions]
collective.easyform = 3.2.0

My schema for the fields

<model xmlns:i18n="http://xml.zope.org/namespaces/i18n" xmlns:marshal="http://namespaces.plone.org/supermodel/marshal" xmlns:form="http://namespaces.plone.org/supermodel/form" xmlns:security="http://namespaces.plone.org/supermodel/security" xmlns:users="http://namespaces.plone.org/supermodel/users" xmlns:lingua="http://namespaces.plone.org/supermodel/lingua" xmlns:easyform="http://namespaces.plone.org/supermodel/easyform" xmlns="http://namespaces.plone.org/supermodel/schema">
  <schema>
    <field name="replyto" type="zope.schema.TextLine" easyform:TDefault="python:member and member.getProperty('email', '') or ''" easyform:serverSide="False" easyform:validators="isValidEmail">
      <description/>
      <title>Your E-Mail Address</title>
    </field>
    <field name="hidden" type="zope.schema.Bool" easyform:serverSide="False" easyform:THidden="False">
      <description/>
      <required>False</required>
      <title>hidden</title>
      <form:widget type="plone.app.z3cform.widget.SingleCheckBoxBoolFieldWidget"/>
    </field>
    <field name="test" type="zope.schema.TextLine" easyform:depends_on="condition:form.widgets.hidden" easyform:serverSide="False" easyform:THidden="False">
      <description/>
      <required>False</required>
      <title>Test</title>
    </field>
  </schema>
</model>
fredvd commented 1 year ago

@Nimo-19 Hi, I ran into other issues while testing this feature on Plone 6. But for Plone 5.2 I assume you at least need to install plone.patternslib as a separate add'on, it adds extra patterns from patternslib that don't conflict with the ones in Plone 5.2.

The pat-depends pattern is included in Plone 6's classicUI patterns.

Nimo-19 commented 1 year ago

But for Plone 5.2 I assume you at least need to install plone.patternslib as a separate add'on

Thanks for the answer. I expected something like this. Should this be documented somehow or should the plone.patternslib be added as an (extra?) dependency to the setup.py? Is it maybe possible to check for an installed Layer for displaying the depends on field?

I would try to come up with a pull request, I'm just not sure what the correct way is.