Problems, need help? Have a tip or advice? Post it here.
5 posts Page 1 of 1
Hello All!

I have a simple DBF.

Code: Select all
<?php require_once( 'couch/cms.php' ); ?>
<cms:template title='DBF-Submit Data Display' clonable='1' >
    <cms:editable name='first_name' label='First Name' type='text' />
    <cms:editable name='last_name' label='Last Name' type='text' />
</cms:template>
<cms:set submit_success="<cms:get_flash 'submit_success' />" />

<cms:if submit_success >
    <h4>Success: <cms:show frm_first_name /> Your application has been submitted.</h4>
</cms:if>


<cms:form
    masterpage=k_template_name
    mode='create'
    enctype='multipart/form-data'
    method='post'
    anchor='0'
    >

    <cms:if k_success >

        <cms:db_persist_form
            _invalidate_cache='0'
            k_page_title=frm_first_name
        />

        <cms:set_flash name='submit_success' value='1' />
        <cms:redirect k_page_link />
    </cms:if>

    <cms:if k_error >
        <div class="error">
            <cms:each k_error >
                <br><cms:show item />
            </cms:each>
        </div>
    </cms:if>


    <label>First Name</label>
    <cms:input name="first_name" type="bound" />
    <br />

    <label>Last Name</label>
    <cms:input name="last_name" type="bound" />
    <br />

    <button type="submit">Submit Application</button>

</cms:form>
<?php COUCH::invoke(); ?>


I am trying to display the first name submitted in the editable field in the success message. But to no luck. This is the condition where the name needs to be displayed.
Code: Select all
<cms:if submit_success >
    <h4>Success: <cms:show frm_first_name /> Your application has been submitted.</h4>
</cms:if>


I have also tried:
Code: Select all
<cms:show first_name />
<cms:get_flash frm_first_name />
<cms:get_flash first_name />


But nothing displays the success block.

Expected output of success should be:
Code: Select all
Success: Priya Your application has been submitted.


Regards,
GenXCoders
Image
where innovation meets technology
Hi,

We can store the name in the 'flash' variable we set right before we redirect -
Code: Select all
<cms:set_flash name='submit_success' value=frm_first_name />
<cms:redirect k_page_link />

The redirected page then can show that value as follows -
Code: Select all
<cms:if submit_success >
    <h4>Success: <cms:show submit_success /> Your application has been submitted.</h4>
</cms:if>

Hope this helps.
@KK Sir,

How is your health now sir? I suppose you are not quite well because I hardly find you online these days. Please take good care of yourself.

What you have suggested actually helps a lot. And it also gets me to the next thing, i.e. I actually have a form that has First Name, Last Name, Email Address, etc. And in the success message the three First Name, Last Name and Email Address need to be displayed.

The success message is like:
Code: Select all
Dear,
[b]First Name Last Name[/b]

Your request has been submitted successfully!

An email of your submission has been emailed to your id [b]Email Address[/b].

Regards,
Team Interns


So how do I do that where multiple values are required to be displayed in the success message.

Once again, thanks for the reply and as always it did help me a lot.

Regards,
GenXCoders
Image
where innovation meets technology
Thank you for your solicitude, @genxcoders. I am better now (though still have some way to go before recovering completely).

Replying to your query,
there can be two solutions -

1. Save in the flash variable your full message e.g.
Code: Select all
<cms:set_flash name='submit_success' value="Dear,
[b]<cms:show frm_first_name /> <cms:show frm_last_name />[/b]

Your request has been submitted successfully!

An email of your submission has been emailed to your id [b]<cms:show frm_email />[/b].

Regards,
Team Interns" />
<cms:redirect k_page_link />

Please notice the use of *double quotes" while setting 'value' parameter above (it is needed because we are using Couch tags in its value).

2. There is no limitation that you can save only one flash variable (or that it has to be named 'submit_success' as we have done in our sample code). You can save all the values submitted through the form as separate flash variable e.g. as follows -

Code: Select all
<cms:set_flash name='submit_first_name' value=frm_first_name />
<cms:set_flash name='submit_last_name' value=frm_last_name />
<cms:set_flash name='submit_email' value=frm_email />
<cms:redirect k_page_link />

Now, instead of 'submit_success', get back the new variables to show them as follows -
Code: Select all
<cms:set submit_first_name="<cms:get_flash 'submit_first_name' />" />

<cms:if submit_first_name >
    <cms:set submit_last_name="<cms:get_flash 'submit_last_name' />" />
    <cms:set submit_email="<cms:get_flash 'submit_email' />" />
   
    Dear,
    [b]<cms:show submit_first_name /> <cms:show submit_last_name />[/b]

    Your request has been submitted successfully!

    An email of your submission has been emailed to your id [b]<cms:show submit_email />[/b].

    Regards,
    Team Interns
</cms:if>

Hope it helps.
@KK Sir,
You are most welcome.
"I pray to the almighty to help you recover to the fullest at the earliest. Amen"

The Solution:
I had no idea that the flash could be used to set multiple values. Now I do.
The solution worked as was expected.

Thanks again.

Regards,
GenXCoders
Image
where innovation meets technology
5 posts Page 1 of 1