Hi,
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:append}
{/custom_fields}
{/exp:channel:form}
But setting a layout variable seems to not be possible/parsed. I get {layout:set:append name='lv_the_fields_name'}the_name_of_my_field{/layout:set:append} in my HTML.
Before having the DRY approach I did show my divs this way (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?
EE version used : 5.2.2
It shouldn’t be unparsed, but I definitely wouldn’t be nesting an embed tag in a loop like that. But I’m not a big fan of using the custom fields loop in general.
Taking a step back, could you achieve the same goal not using the loop but hand coding the design- I typically use {field:my_field_name} as my standard approach to outputting fields in the channel form.
If that’s not a great option- walk me through the engold. What was on those modify/help{field_name} templates?
Hi Robin, thanks for the reply.
I know, it is not very beautiful with embeds into the custom_fields loop, that is why I want to achieve this with the layouts approach instead.
I cannot hand code the design as I have to keep it very generic/standard, so I can re-use it for multiple types of content. So, I have to use the {custom_fields} loop to achieve my goal, that is :
The editor can update the contents of his site on the front-end via channel form. For each field I have a sliding help panel about it that contains several HTML structured information about what he can put in (proper to each of the fields) etc…. That is the purpose of {embed="modify/_help_myfield"}.
But, instead of placing {embed="modify/help{field_name}”} into {custom_fields} loop I want to append the custom field’s name into a layout variable (named lv_the_fields_name for example) and use this layout variable array into the wrapper layout to show for each of these an embed whose name is {embed="modify/help{field_name}”}, like this :
{layout:lv_the_fields_name}
{embed="modify/_help_{value}"}
{/layout:lv_the_fields_name}
but the {layout:set:append} tag seems to stay unparsed.
Don’t know if it is very clear (it is in my head but…), please tell me if it is not, english is not my mother tongue.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.