Form (multiple checkbox/select, Autoresponder)

5 replies·opened Feb 28, 2023
N
nperroFeb 28, 2023

Hello,

I'm trying to make a form with a checkbox which we can select as many as we want.

I succeed to make a form and receive the mail to my company email address
but in the autoresponder email, it doesn't show the answers.

These two doesn't show any answers in autoresponder email.
contact-form-興味のあるオプショナルツアー[]
realestate-enquiry-projects[]

I prefer to use the checkbox than the multiple select.

ID and Password for the demo site are below.
ID :kagura
Password: kagura0980

If you need more information, please let me know.

【Form.html】

<div class="form-group" id="contact-form-optionaltour">
                                                <label class="form-check-label nott"
                                                    for="contact-form-optionaltour">興味のあるオプショナルツアー(複数回答可) <span
                                                        class="form-required">必須</span></label>
                                                <div class="form-check">
                                                    <label for="contact-form-optionaltour-1"><input
                                                            class="form-check-input required valid checkbox"
                                                            type="checkbox" name="contact-form-興味のあるオプショナルツアー[]"
                                                            id="contact-form-optionaltour-1"
                                                            value="日本って何だろう?~心のふるさと伊勢神宮を訪ねて~(3~4時間程度)">
                                                        日本って何だろう?(3~4時間程度)</label>
                                                    <label for="contact-form-optionaltour-1"><input
                                                            class="form-check-input required valid checkbox"
                                                            type="checkbox" name="contact-form-興味のあるオプショナルツアー[]"
                                                            id="contact-form-optionaltour-2"
                                                            value="日本って何だろう?~心のふるさと伊勢神宮を訪ねて~30分程度">
                                                        日本って何だろう?(30分程度)</label>
                                                    <label for="contact-form-optionaltour-3"><input
                                                            class="form-check-input required valid checkbox"
                                                            type="checkbox" name="contact-form-興味のあるオプショナルツアー[]"
                                                            id="contact-form-optionaltour-3" value="お伊勢参り全部廻り">
                                                        お伊勢参り全部廻り</label>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label>Projects:</label>
                                                <select class="form-select required valid"
                                                    name="realestate-enquiry-projects[]"
                                                    id="realestate-enquiry-projects" multiple="" aria-invalid="false">
                                                    <option value="Future Apartments">Future Apartments</option>
                                                    <option value="Amazing Condo Groups">Amazing Condo Groups</option>
                                                    <option value="City Residency">City Residency</option>
                                                    <option value="Prime Housing Society">Prime Housing Society</option>
                                                    <option value="Kings Villa Groups">Kings Villa Groups</option>
                                                </select>
                                                <label id="realestate-enquiry-projects-error" class="error"
                                                    for="realestate-enquiry-projects" style="display: none;"></label>
                                            </div>

【Form.php】
$ar_message = !empty( $submits['ar_message'] ) ? $submits['ar_message'] :

【お名前】{contact-form-お名前}&lt;br&gt;
【フリガナ】{contact-form-ふりがな}&lt;br&gt;
【Email】{contact-form-email}&lt;br&gt;
【電話番号】{contact-form-電話番号}&lt;br&gt;
【ご希望の連絡方法】{contact-form-ご希望の連絡方法}&lt;br&gt;
【興味のあるオプショナルツアー】&lt;br&gt;
{contact-form-興味のあるオプショナルツアー[]}&lt;br&gt;
【伊勢旅行の予定 】&lt;br&gt;
{contact-form-伊勢旅行の予定}&lt;br&gt;
【相談内容】&lt;br&gt;
{contact-form-相談内容}&lt;br&gt;
【ご相談内容詳細】&lt;br&gt;
{contact-form-ご相談内容詳細}&lt;br&gt;
プロジェクト&lt;br&gt;
{realestate-enquiry-projects[]}&lt;br&gt;
S
SemiColonWebSTAFFMar 7, 2023

Hello,

Thanks for your Kind Patience and Apologies for the Delays in replying!

Since the Multiple Checkbox is an Array, the standard input is currently not designed to work with the Default Settings. We will release an update soon to address this. Meanwhile, you can find the following code in the include/form.php File:

if( !empty( $ar_matches[1] ) ) {
	foreach( $ar_matches[1] as $ar_key => $ar_value ) {
		$ar_message = str_replace( '{' . $ar_value . '}' , $submits[ $ar_value ], $ar_message );
	}
}

and replace it with:

if( !empty( $ar_matches[1] ) ) {
	foreach( $ar_matches[1] as $ar_key => $ar_value ) {
		$ar_message = str_replace( '{' . $ar_value . '}' , ( is_array($submits[ $ar_value ]) ? explode( ', ', $submits[ $ar_value ] ) : $submits[ $ar_value ] ), $ar_message );
	}
}

Additionally, replace {realestate-enquiry-projects[]} with {realestate-enquiry-projects} in your code.

This should work fine. Hope this Helps!

Let us know if we can help you with anything else or if you find any further issues.

N
nperroMar 10, 2023

Thank you for your reply!

I tried your new code but it didn't work. It posted only the last selection.

I have only 4 days left for the support so I will leave this for this time and wait for the new version for the next time.

Thank you.

S
SemiColonWebSTAFFMar 10, 2023

Hello,

Apologies, there was a mistake in the code.

Please consider using this code instead:

if( !empty( $ar_matches[1] ) ) {
	foreach( $ar_matches[1] as $ar_key => $ar_value ) {
		$ar_message = str_replace( '{' . $ar_value . '}' , ( is_array($submits[ $ar_value ]) ? implode( ', ', $submits[ $ar_value ] ) : $submits[ $ar_value ] ), $ar_message );
	}
}

This will definitely work fine. Hope this Helps!

Let us know if we can help you with anything else or if you find any further issues.

N
nperroMar 10, 2023

Thank you for your prompt reply.

It worked!

Thanks a lot for your support!!

I would appreciate if you can make a form with a checkbox for your future product.

S
SemiColonWebSTAFFMar 10, 2023

Super Glad the issue was resolved! We are more than Happy to Help! :)

We will be definitely adding more Form Layouts in the Future Updates of Canvas.

Please do let us know if we can help you with anything else.

Have the same question, or something new?

Sign in to the Canvas dashboard to reply or open your own topic. Canvas owners get direct help from the SemiColonWeb team.

Reply on the dashboard