mask icon indicating copy to clipboard operation
mask copied to clipboard

BE: show only limited options based on pre-selection / change options based on pre-selection

Open medarob opened this issue 4 years ago • 4 comments

I'm not sure if that are two different things or if these two features are somehow connected.

Sometimes it's not necessary to show all available options or fields in a content element in the BE view. So it would be good to limit the view of available options/fields based on a selected option of another field.

Example: You have two select dropdown fields called "Layout" and "Columns".

The "Layout" field has two options: Layout 1, Layout 2 The "Columns" field has the following options: 1, 2, 3, 4, 5

Now, if you choose "Layout 1" the "Column" options should only consists of "1, 2, 3" whereas if you choose "Layout 2" all 5 options should be available.

It would be also good to show/hide complete CE fields based on a selected option in a CE. For example if there is a 3rd option in the Layout field: Layout1, Layout 2, Layout 3 If the user chooses "Layout 3" then the "Columns" field should be hidden or not available at all.

Based on a selection, another field should have different values.

Example There are two select dropdowns: "Layout" and "Color" Layout has the following options: "Light Mode" and "Dark Mode". Color has the following options if "Light Mode" was selected: "black", "dark blue". Color has the following options if "Dark Mode" was selected: "white", "light blue".

So, based on the selected option in the Layout field the text and values in one or more fields should change. So that an editor would only see the options available in this context.

It's also possible that there are more or less fields, based on the choosen option.

I asked @IchHabRecht and was told that it should be possible with ItemProcFunc but I don't know how to integrate this. https://docs.typo3.org/m/typo3/reference-tca/master/en-us/ColumnsConfig/Type/selectSingle.html#itemsprocfunc

So, maybe 1) and 2) are already possible without any further changes? If that is the case, could you please add some examples in the documention in how to achive this behaviour? However, an editor friendly way would be really great, if that is even possible (so that I don't have to manually change the code).

medarob avatar Oct 19 '20 11:10 medarob

Hi @medarob ! Thanks for the feature request. Yes, these are two different features. One of them you described already. This is helpful to control select options. To hide fields completely you need to add displayCond. https://docs.typo3.org/m/typo3/reference-tca/master/en-us/Columns/Index.html?highlight=displaycond#displaycond Everything is possible already by manually manipulating the generated tca of mask. To add these features directly into mask is not planned yet. (but it's on the list)

nhovratov avatar Oct 19 '20 13:10 nhovratov

Hi @medarob ! Thanks for the feature request. Yes, these are two different features. One of them you described already. This is helpful to control select options. To hide fields completely you need to add displayCond. https://docs.typo3.org/m/typo3/reference-tca/master/en-us/Columns/Index.html?highlight=displaycond#displaycond Everything is possible already by manually manipulating the generated tca of mask. To add these features directly into mask is not planned yet. (but it's on the list)

Could you provide a snippet on how to do this? I understand that I have to manipulate the Jason file and add the reload- and diplaycondition-part manually. I managed to find a way to force a reload when a select-field is changed, but, however, when I try to add or change a field in the backend, the Jason file gets rewritten, so my changes are gone...

tohett avatar Aug 04 '22 17:08 tohett

@tohett Hey, you misunderstood me. I meant the real TCA, not the tca part in the JSON file. You would do it like any other TCA/Overrides. Here is the documentation on how to do it with Mask: https://docs.typo3.org/p/mask/mask/7.2/en-us/Guides/OverrideTCA.html

nhovratov avatar Aug 05 '22 23:08 nhovratov

@tohett Hey, you misunderstood me. I meant the real TCA, not the tca part in the JSON file. You would do it like any other TCA/Overrides. Here is the documentation on how to do it with Mask: https://docs.typo3.org/p/mask/mask/7.2/en-us/Guides/OverrideTCA.html

Ahhh, thank you, I will give it a try!

Edit: Tried it and works as described! Thanks again!

tohett avatar Aug 08 '22 06:08 tohett