terminal42 / contao-conditionalformfields

Display form fields conditionally in Contao Open Source CMS
MIT License
18 stars 12 forks source link

Complex conditions #23

Closed m-vo closed 4 years ago

m-vo commented 6 years ago

I'm in a situation where there is a field with a date of birth and a section of form fields that should only be displayed for users under 18 years of age.

Does anyone of you see a simple solution for that? I'd be happy to enhance the capabilities (e.g. supporting more expression functions) of this extension, but I'm not sure what would be the right approach to do so.


Btw: On a side note it might be helpful to allow for < and > in the conditions as this is something that works across PHP and JS. Right now those characters are encoded (&lt; / &gt;). Wdyt?

Toflar commented 6 years ago

Expressions should be stored as raw data (maybe that's a bug indeed). And I don't think that the expression should support such complex stuff because it has to work in both languages. Maybe it's better to provide extension points (or you just write your own widget for that) :)

m-vo commented 6 years ago

And I don't think that the expression should support such complex stuff because it has to work in both languages.

Maybe the JS evaluation could be replaced with an ajax request, so that all logic is on the PHP side?

Toflar commented 6 years ago

Yes, that was my initial plan and using Symfony's Expression Language. But that was not possible back in the days ;-) But I'm very open for a version 3 if you need that and want to work on a solution :)

m-vo commented 6 years ago

Symfony's Expression Language sounds like a good idea. Should this then go in a new repository as a native bundle / Contao4 only? (not saying, that I'd start right away :wink:)

Toflar commented 6 years ago

It can just become version 3, imho. Because it would be pretty different (conditions would not work anymore etc.). Maybe they could be upgraded ;-)