New: Learn Statamic on Laracasts!

We've retired the forum in favor of GitHub Discussions.

New conversations can be started on GitHub. Existing conversations will remain for a while longer.

Head over to GitHub →

v2: Conditional content disappears

Kaz van Kooten November 2, 2020 by Kaz van Kooten

Alright, so my v2 fieldset starts with a select field:

  type: select
    nothing: 'Show nothing'
    first: 'Show first'
    second: 'Show second'

When nothing is selected, the rest of the fieldset is empty. Every other field in my fieldset has a show_when field. For the sake of simplifying things: when first is selected, fields 1, 2 and 3 are shown and when second is selected, fields 4, 5 and 6 are shown.

The template is set up accordingly, with things like {{ if mySelect == 'first' }} ... {{ elseif mySelect == 'second' }} ... {{ /if }}.


When I choose first and save the page, reload, then choose second and edit, the content I entered in the fields showing when first is selected are reset. Is there a way to keep all this content stored, so that I can easily switch between options?

(edit: typo)

>>>>>>> Unanswered <<<<<<<
3 Replies