0

I re-code a website using DRY principles with layouts and layouts variables but I get stuck with this :

Into a channel form I have to store each {field_name} into a {layout:set:append} so I can loop through this list into the layout template and dynamically show some stuff based on the fields name.

{exp:channel:form channel="mychannel" entry_id="{segment_3}"}
    {custom_fields}
        {layout:set:append name='lv_the_fields_name'}{field_name}{/layout:set}
    {/custom_fields}
{/exp:channel:form}

But setting a layout variable into channel form seems to not be possible/parsed. I get {layout:set name='lv_the_fields_name'}the_name_of_my_field{/layout:set} in my HTML.

Before having the DRY approach I did show my divs this way in EE3+ (that was not beautiful but worked) :

{exp:channel:form channel="mychannel" entry_id="{segment_3}"}
            {custom_fields}
            <section class="cd-help-field field_{field_name}">
                    {embed="modify/_help_{field_name}"}
            </section>
            {/custom_fields}
{/exp:channel:form}

This technique worked in EE3+ but not anymore in EE5… it shows {embed="modify/_help_myfield"}

Is there a bug into channel form for EE5+ or does somebody know how I can achieve this please?

1 Answer 1

0

You are almost there - you just need to correct your syntax. To close a layout:set:append tag you need to use the same tag - i.e. /layout:set:append - you left off :append from the closing tag.

So try this:

{exp:channel:form channel="mychannel" entry_id="{segment_3}"}
    {custom_fields}
        {layout:set:append name='lv_the_fields_name'}{field_name}{/layout:set:append}
    {/custom_fields}
{/exp:channel:form}

HTH

4
  • that is absolutely correct! Thanks. Shame on me! I tried but still doesn't work. Now displays : {layout:set:append name='lv_the_fields_name'}the_name_of_my_field{/layout:set:append}
    – pikarge
    Apr 30, 2019 at 14:06
  • Well that's odd. Often when you see the tag text appearing in HTML output rather than php errors of some kind it is a symptom of a syntax error somewhere in the associated EE tags - so check for typos - things like mixing up " and ' quotes, missing } or as you had before having the opening and closing tags not having appropriate text etc. May 1, 2019 at 7:49
  • Still stuck with this. Checked all the syntax reduced to it strict minimum but everything is fine and nothing works. I posted it as a bug on the GitHub bug tracker more than a month ago but it has not been assigned yet.
    – pikarge
    Jun 17, 2019 at 14:29
  • There are known odditites with the {exp:channel:form} tag - it does not fully behave like other EE tags - in particular it does not echo all the functions of the {exp:channel:entries} tag. I don't know what the cause of this issue is, but possibly you cannot create new layout entries within a channel form tag. A work around would be to put an {exp:channel:entries} tag on an earlier template in the sequence and write the layout variable from that, and recall the layout variable later (where ever the one you are trying to create goes). Good luck! Jun 17, 2019 at 23:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.