Coded something up in Couch in an interesting way? Have a snippet or shortcode to share? Post it here for the community to benefit.
17 posts Page 2 of 2
KK, that's the solution! :lol:

To have the same error styling as the rest of the dynamic form the final code becomes:
Code: Select all
<cms:form anchor='0' method="post">

    <cms:if k_success>
        <!-- take action using the submitted data - like email -->
        <p>Thank you. We´ll get back to you soon.</p>
        <cms:each k_success sep='\n'>
            <cms:show item /><br>
        </cms:each>
    </cms:if>
   
    <cms:show_repeatable 'form' >

        <cms:php>
            global $FUNCS, $CTX;
            $name = $FUNCS->get_clean_url( $CTX->get('title') );
            $CTX->set( 'name', $name );
        </cms:php>

        <p>
        <label for="<cms:show title />"><cms:show title /></label>
        <cms:input
            type="<cms:if type='email'>text<cms:else /><cms:show type /></cms:if>"
            name="<cms:show name/>"
            id="<cms:show name/>"
            required="<cms:show required />"
            validator="<cms:if type='email'>email</cms:if>"
            validator_msg="<cms:if text>required=<cms:show text /><cms:if type='email'> | email=<cms:show text /></cms:if></cms:if>"
            opt_values="<cms:show options />"
        />
        </p>
       
        <cms:set my_error="<cms:get "k_error_<cms:show name/>" />" />
        <cms:if my_error>
            <div class="alert">
            <p id="<cms:show name/>_error" class="error"><cms:show my_error /></p>
            </div>
        </cms:if>

    </cms:show_repeatable>
   
    <label class="required" for="human">Are you human? Is sky <strong>blue</strong> or green? (4 characters required)</label>
    <cms:input type="text" required='1' validator='regex=/^blue$/i' class="input-text required-entry" id="human" name="human"/>
    <cms:if k_error_human>
        <div class="alert">
            <p>Please answer the question</p>
        </div>
    </cms:if>

    <input type="submit" value="Submit"/>

</cms:form>
I want to bump this post...
What do I need to add to the dynamic form script to send the message to the emailaddress of the person who requested information?

The input field is:
Code: Select all
<input type="text" name="emailaddress"  id="emailaddress" value="" />


This is where the bcc code goes:
Code: Select all
<cms:send_mail from=k_email_from to='k_email_to' bcc='**********' subject='Contactform website'>
    <cms:each k_success sep='\n'>
        <cms:show item /><br>
    </cms:each>
</cms:send_mail>


I've looked for a solution on the forum but couldn't find one.
Upon successful form submission (i.e. in k_success block), all form fields are made available as variables that have a 'frm_' prepended to the field name (this is explained in the docs - http://www.couchcms.com/docs/concepts/forms.html).

Your particular example can be handled as follows -
cms:send_mail from=k_email_from to='k_email_to' bcc=frm_emailaddress subject='Contactform website'>

Hope this helps.
Thanks again KK for the solution.
Didn't know about the frm_' prepend until now. :D
Sorry for bumping this thread, but i don't see any post more fitting than this.

If we parse some values (Text=value) in a dropdown or radio input, how could we access both the Text and the Value (or Label+Text+Value) if we don't know beforehand the names of those fields?

I was trying something like this in the k_success block:
Code: Select all
<cms:show_repeatable 'form'><cms:show frm_???? /> : <cms:show title />&nbsp</cms:show_repeatable>


That does gives me the correct title (Label), but i can't get the submitted value without knowing the tag beforehand.
@LordNeo, the 'k_success' variable itself can be used to access all submitted values without specifying the names - please see http://docs.couchcms.com/concepts/forms ... nd-k_error

Does it help?
KK wrote: @LordNeo, the 'k_success' variable itself can be used to access all submitted values without specifying the names - please see http://docs.couchcms.com/concepts/forms ... nd-k_error

Does it help?

That can dump all the variables non-stop.

Of all the variables i have 1 dropdown that is using the "text=value" in order to set the text as some sort of "Subject" and the real value as the email where it should be sent.
So instead of using a if/else statement (that would be hardcoded) to select the email, i would like to use the text part as subject and the value part as the "to".

PS: Thinking outloud about this i should probably separate that outside the dynamic form...
17 posts Page 2 of 2