- Issue created by @coaston
- π©πͺGermany jurgenhaas Gottmadingen
Your last sentence is extremely helpful. The difference between the 2 is this:
"Form field: set disabled" uses
$element = &$this->getTargetElement()
to find the form element to deal with."Form field: add state" uses the same statement, followed by
$element = &$this->jumpToFirstFieldChild($element)
which receives the first field child to which the state flag is then added.I can see how this may behave different if you have a multi-value field, like date fields with date and time inputs. I wonder if this should be resolved by also supporting state for containers, like e.g. a wrapper around a complex widget?
- πΈπ°Slovakia coaston
thank you, it seems you are right.
I have also tested with custom_field β module and it does not hide the field by default when the widget is "Stacked" however when you change it to Flaxbox and use "fieldset" or "details" type of Wrapper it works.
So I wanted to replicate the same as you suggested with the date and for me the fastest way is to use field_group β module, so I added field group HTML element , with "div" element and added extra CSS class "datewrapper" and added CSS like
.datewrapper { padding: 10px; border: 1px solid #ccc; background-color: #f9f9f9; }
However I can still see the date field , of course the css is applied correctly, but still not working with visibility. I have tried also with fieldset type of field group with the same result :(
Any suggestion? Any advice would be greatly appreciated.
- πΈπ°Slovakia coaston
It works now..yupii.
Instead of field group i used ECA directly.
Form:add grouping element and I have added element name like "datex" , title and fields just field_date so I was able to use element name "datex" as my field name of Add state.
However as Title is required i was not happy with details wrapper so I added additional "form: add container element" and element name "datex" so now everything works as expected.
However I am not sure how this "form: add container element" works.
I think I do not need both forms at the same time but currently this is my workaround.Do you think there can be any patch created which will add container to date fields by default so no need to do such "workarounds"?
- π©πͺGermany jurgenhaas Gottmadingen
I haven't tried myself, but if wrapping the field with a group, it may also work without that group by targeting the already existing wrapper of the multi value field. So instead of going after
field_abc[0][value]
, have you tried just usingfield_abc
? - πΈπ°Slovakia coaston
Yeah I did, it works for all types, except the date field.
- π©πͺGermany killah89 Schneverdingen
I added a model with action, form field: add state "invisible" and created some others to add state if bool is 1. How i can revert state to "invisible" when my bool field is unchecked (0)? Its only working, when im set state to "disabled", but i want to hide a field, if bool is unchecked (0).
- πΈπ°Slovakia coaston
Hi killah89,
Use visible when bool field has value 1.
So unchecked or 0 will be hidden.Or you can try option "empty", but above one works fine.
However this is different topic related to date field in modal dialog windows, so you should raise a new one if above wont work.
- π©πͺGermany jurgenhaas Gottmadingen
- πΈπ°Slovakia coaston
Actually #7 is my answer to your question jurgenhass.
If there is not any plan to provide a patch i think this topic can be closed as this workaround with Form:add grouping element is quite a good one.
- π©πͺGermany jurgenhaas Gottmadingen
Not sure if we can provide something generic for the date field that doesn't break other stuff at the same time. And that's not only relevant for form states, as the methods
$element = &$this->getTargetElement()
and&$this->jumpToFirstFieldChild($element)
are used by other form field related actions as well.It may require some deeper analysis of the nature of the date field widget to find out why that fails, and also if there are other field widgets that have similar issues.