0

This question already has an answer here:

i have one doubt / question and don't know how to solve it: Imagine you have a subform-field with the multiple-parameter active to add multiple content-blocks, now, the thing is, in real life there are many cases where not every block has the same content / fields. I want to achieve the following: To have a select or something else, wich can show / hide fields dynamically with javascript in the backend. So if the user for instance selects "Content type A" within that select field, certain fields will be shown, if he selects "Content type B", other fields are visible. If paired with a subform, you could add as many blocks as you want, with each block with selectable content-type with different fields. Is this possible?

Thanks in advance Best regards

[edit]: Ok, some example code, lets say you have a subform field:

<field
  type="subform"
  name="blocks"
  formsource="..."
  multiple="true"
  label="My repeatable blocks" />

And the subform looks like this:

<form>
  <field
    type="list"
    name="type"
    label="Block type">
    <option value="standard">Standard Block</option>
    <option value="twocol">Two column Block</option>
  </field>
  <field
    type="editor"
    name="leftcol"
    label="Main Description" />
  <field
    type="editor"
    name="rightcol"
    label="Right column" />
</form>

Ok, the question i have: is it possible to execute javascript; when the user selects "Standard page" only the first editor is shown, if he selects Two columns, both are shown. Note that this is only a simple example, there are other, much more complicated examples with 4-5 block-types (the client should have the possibility to manage more content-block-types dynamically, perhaps insert a gallery, then insert a two-column test, then a single block then.. you get the idea). And if all fields are shown for every block, every single subform block is huge in the backend...

marked as duplicate by mickmackusa, TryHarder, Joomler, Neil Robertson, Lodder Jul 2 at 9:12

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Your question is a bit Too Broad and lacks context, proof of research, and an attempt to self-solve. If you are looking for a Joomla developer, this isn't the place to hire one. If you are looking for assistance with your development, please show us some sample form html, what you expect to achieve functionally and how far you have come with your development. When you show us exactly where you are stuck, your question can be clearly and concisely answered. – mickmackusa May 27 at 11:22
  • 1
    Hi, i've updated the question with a specific example.. – pixx Jun 13 at 8:27
  • 1
    How about showon? joomla.stackexchange.com/a/14022/12352 – mickmackusa Jun 13 at 8:39
  • Hey, this works great!! If you want, you can repost your comment as answer, so that i can accept it! – pixx Jun 14 at 10:05
  • That's not the appropriate resolution. I will mark this question as a duplicate. Please upvote the solution on the other page. – mickmackusa Jun 14 at 10:19