1

Forms: 3.5.3

ExpressionEngine: 2.11.1

I have a fairly long form that has where a good portion of the fields are setup in 2 columns - that layout is used when viewing/entering data into the form itself. But when I output submissions to the form using the {exp:forms:entries} tag, the output is all in a single column (the fields are also not in the same order as they are when editing/viewing the form itself, but that's a separate issue).

Is there any way to make the output of the {exp:forms:entries} use the same layout as the {exp:forms:form} tag?

Edit: just occurred to me, is it possible that using columns is the cause of the entries tag not displaying fields in the correct order?

1

Does DevDemon no longer support this software? This is the method the devdemon.com website recommends on their website for obtaining support, since their support forum is now read-only - but for more than a month, there's been no response to this & another Forms-related question I've posted.

Anyway, I ended up cobbling together a workaround, requiring a number of add-ons:

Stash - https://devot-ee.com/add-ons/stash String Explode Tag - https://devot-ee.com/add-ons/string-explode-tag Find and Replace Plus VMG Nested

StackExchange won't allow posting the last 2 links... but both should be easy enough to find through google/devot-ee. Here's the code:

{exp:query sql="select field_id, title as field_title, description, field_type, field_settings, field_order from exp_forms_fields WHERE (form_id = '9' AND parent_id = '' AND field_type != 'pagebreak' AND field_type != 'hidden_field' AND field_id != '350' ) ORDER BY field_order"}
    {if field_type == "html"}
        {exp:replace_plus find=";s|:QUOTE:" replace="" multiple="yes"}{exp:strexplode delimiter=":" string='{field_settings}' index="6"}{/exp:replace_plus}
    {if:elseif field_type == "columns_2"}
        <p>
            <!-- field_title: {field_title} -->
            {if "{field_title}" != "2 Columns"}<span class="column-title"><strong>{field_title}</strong></span><br />{/if}
            {!-- QUERY TO GET "CHILD" FIELDS --}
            {exp:vmg_nested:query prefix="column" sql="select field_id, title as field_title, field_type, field_settings from exp_forms_fields WHERE (form_id = '9' AND parent_id = '{field_id}') ORDER BY field_order" parse="inward"}
                <strong>{column:field_title}:</strong> 

                {!-- QUERY TO GET CHILD FIELD DATA --}
                {embed="snippets/child-field-data" field_id="{column:field_id}" segment_4="{segment_4}" fentry_query="{exp:stash:get name='fentry_query'}"}
                {!-- /QUERY TO GET CHILD FIELD DATA --}

            {/exp:vmg_nested:query}
            {!-- /QUERY TO GET "CHILD" FIELDS --}
        </p>
        <p>&nbsp;</p>
    {if:elseif field_type == "file_upload"}
        <p><strong>{field_title}: </strong><br />
        {if "{description}" != ""}<br /><small><em>{description}</em></small><br />{/if}
        {!-- QUERY TO GET FIELD DATA --}
            {exp:vmg_nested:query prefix="data_reg" sql="select fid_{field_id} from exp_forms_entries WHERE (form_id = '9' AND fid_371 = '{segment_4}' AND fid_{field_id} !='') LIMIT 1"}
                {if "{data_reg:fid_{field_id}}" != ""}
                    <a href="/library/form-uploads/{data_reg:fid_{field_id}}"><img style="max-width: 70%; height: auto;" src="/scripts/thumbgen/thumbgen.php?src=/library/form-uploads/{data_reg:fid_{field_id}}&w=800" /></a>
                    <br />
                {/if}
                <em>{data_reg:fid_{field_id}}</em>
            {/exp:vmg_nested:query}
        {!-- /QUERY TO GET FIELD DATA --}
    {if:else}
        <p><strong>{field_title}: </strong>
        {if "{description}" != ""}<br /><small><em>{description}</em></small><br />{/if}
        {!-- QUERY TO GET FIELD DATA --}
            {exp:vmg_nested:query prefix="data_reg" sql="select fid_{field_id} from exp_forms_entries WHERE (form_id = '9' AND fid_371 = '{segment_4}' AND fentry_id = '{segment_5}') LIMIT 1"}
                {data_reg:fid_{field_id}}
            {/exp:vmg_nested:query}
        {!-- /QUERY TO GET FIELD DATA --}
        </p>
    {/if}
{/exp:query}

And the contents of the embedded "snippets/child-field-data" template are:

{!-- QUERY TO GET CHILD FIELD DATA --}
    {exp:query sql="select fid_{embed:field_id} from exp_forms_entries WHERE (form_id = '9' AND fid_371 = '{embed:segment_4}' {embed:fentry_query}) LIMIT 1"}

        <!-- query: select fid_{embed:field_id} from exp_forms_entries WHERE (form_id = '9' AND fid_371 = '{embed:segment_4}') LIMIT 1<br /> -->
        {!-- GET THE FIELD TYPE --}

        {exp:stash:set name="fielddatatype"}{exp:replace_plus find=":QUOTE:|;s" replace="" multiple="yes"}{exp:strexplode delimiter=":" string='{fid_{embed:field_id}}' index="4"}{/exp:replace_plus}{/exp:stash:set}
        {exp:stash:set name="nameorarea"}{exp:replace_plus find=":QUOTE:|;s" replace="" multiple="yes"}{exp:strexplode delimiter=":" string='{fid_{embed:field_id}}' index="6"}{/exp:replace_plus}{/exp:stash:set}
        {exp:stash:set name="lastnameorphone"}{exp:replace_plus find=":QUOTE:|;:RD:" replace="" multiple="yes"}{exp:strexplode delimiter=":" string='{fid_{embed:field_id}}' index="10"}{/exp:replace_plus}{/exp:stash:set}

        {if "{exp:stash:get name='fielddatatype'}" == "first_name"}
            {exp:stash:get name='nameorarea'} {exp:stash:get name='lastnameorphone'}
        {if:elseif "{exp:stash:get name='fielddatatype'}" == "area"}
            {if "{exp:stash:get name='nameorarea'}" !=""}({exp:stash:get name='nameorarea'}) {exp:stash:get name='lastnameorphone'}<br />{/if}
        {if:else}
            {fid_{embed:field_id}}
        {/if}

        <br />
    {/exp:query}
{!-- /QUERY TO GET CHILD FIELD DATA --}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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