Forums

show the captcha in "Custom forms HTML code" include

brostalski 05 Mar, 2015
Hi!

I have several "custom forms" with many "events". Some of these events are repeated like "custom code", "load js" or "email" (template). Now i will exclude this code to files in my specific folder 'templates_inc' to manage and chage it one time only.

I have a file with my "custom form" like this
<h1>Kontakt</h1>
<div class="ccms_form_element cfdiv_text" id="firma_container_div" style=""><label>Firma</label><input maxlength="150" size="30" class="" title="" type="text" value="" name="firma" />
<div class="clear"></div><div id="error-message-firma"></div></div><div class="ccms_form_element cfdiv_text" id="vorname_container_div" style=""><label for="vorname">Vorname</label><input id="vorname" maxlength="150" size="30" class="" title="" type="text" value="" name="vorname" />
<div class="clear"></div><div id="error-message-vorname"></div></div><div class="ccms_form_element cfdiv_text" id="name_container_div" style=""><label for="name">Name *</label><input id="name" maxlength="150" size="30" class=" validate['required']" title="" type="text" value="" name="name" />
<div class="clear"></div><div id="error-message-name"></div></div><div class="ccms_form_element cfdiv_text" id="strasse_container_div" style=""><label>Straße</label><input maxlength="150" size="30" class="" title="" type="text" value="" name="strasse" />
<div class="clear"></div><div id="error-message-strasse"></div></div><div class="ccms_form_element cfdiv_text multiline_start" id="plz_container_div" style=""><label for="plz">PLZ / Ort</label><input id="plz" maxlength="5" size="5" class="cb_postcode validate['number']" title="" type="text" value="" name="plz" />
<div class="clear"></div><div id="error-message-plz"></div></div><div class="ccms_form_element cfdiv_text multiline_add" id="ort_container_div" style=""><label style="display:none;">Ort</label><input maxlength="150" size="19" class="cb_town" title="" type="text" value="" name="ort" />
<div class="clear"></div><div id="error-message-ort"></div></div><div class="ccms_form_element cfdiv_text" id="telefon_container_div" style=""><label>Telefon</label><input maxlength="150" size="30" class=" validate['phone']" title="" type="text" value="" name="telefon" />
<div class="clear"></div><div id="error-message-telefon"></div></div><div class="ccms_form_element cfdiv_text" id="email_container_div" style=""><label>E-Mail *</label><input maxlength="150" size="30" class=" validate['required','email']" title="" type="text" value="" name="email" />
<div class="clear"></div><div id="error-message-email"></div></div><div class="ccms_form_element cfdiv_textarea" id="nachricht_container_div" style=""><label for="nachricht">Nachricht *</label><textarea id="nachricht" cols="39" rows="12" class=" validate['required']" title="" name="nachricht"></textarea>
<div class="clear"></div><div id="error-message-nachricht"></div></div><div class="ccms_form_element cfdiv_text" id="chrono_verification_container_div" style="">
		<label>Code *</label>
		<div id="chrono_verification_container_captcha">
			{chronocaptcha_img}<br /><br />
			<input maxlength="10" size="10" class="chrono_captcha_input validate['required']" title="" type="text" value="" name="chrono_verification" /> {chronocaptcha_refresh}
		</div>
		<div class="clear"></div>
		<div id="error-message-chrono_verification"></div>
	</div><div class="ccms_form_element cfdiv_submit" id="submit_container_div" style="text-align:left">
<div id='messagebuttons'>
<button type='reset' name='reset' id='reset' class='btn btn-leeren'></button> 
<button type='submit' name='senden' id='senden' class='btn btn-absenden'></button> 
</div>
<div class="clear"></div></div>
<br />
<p>* Pflichtfelder</p>


and this
<?php include(JPATH_BASE."/templates_inc/forms/contact/form.php"); ?>

to include in the chronoforms field. The same with the "load js" event.

My first "custom form" works but not the captcha_img. I changed the {} to <?php ?> but i see no captcha. What can i do?
GreyHead 05 Mar, 2015
Hi Brostalski,

Do you have a Load Captcha acion in the form On Load event?

Bob
brostalski 05 Mar, 2015
Hi Bob,

yes i have.
[attachment=0]onload.JPG[/attachment]

The events work if i leave the form code here
[attachment=1]form.JPG[/attachment]

When i set the inlcude, the captcha don't work. Is there a other syntax for the {chronocaptcha_img} and {chronocaptcha_refresh}?

greetz
brostalski
brostalski 06 Mar, 2015
Hi!

i found the problem in
/administrator/components/com_chronoforms/form_actions/load_captcha/load_captcha.php
on line 33. The $form->form_details->content is empty, so the str_replace can not work.
GreyHead 06 Mar, 2015
Hi Brostalski,

You can include the full Captcha Image HTML in your Custom Code

Or, and IMHO better, Include only part of the HTML in your form using a Custom Code element (or elements) and add the Captcha and Submit buttons in the Designer tab.

Bob
brostalski 06 Mar, 2015
Hi Bob,

thanks for your idea - i worked on an other solution and solved my problem.

I make an custom form action "load_captcha_custom" (update save) and save the captcha image and refresh button in the $form-data.

load_captcha_custom.php
$form->data['chronocaptcha_img'] = '<img src="'.$CF_PATH.'components/com_chronoforms/chrono_verification.php?imtype='.$params->get('fonts', 0).'" alt="" id="imgver_'.$actiondata->id.'" />';
$form->data['chronocaptcha_refresh'] = '<img src="'.$CF_PATH.'administrator/components/com_chronoforms/form_actions/load_captcha_custom/refresh.png" class="captcha-refresh" alt="refresh" title="Code erneuern" onclick="document.getElementById(\'imgver_'.$actiondata->id.'\').src = \''.$CF_PATH.'components/com_chronoforms/chrono_verification.php?imtype='.$params->get('fonts', 0).'\' + \'&\' + Math.random();" />';


form.php (include in custom forms html code)
<div id="chrono_verification_container_captcha">
<?php echo $form->data['chronocaptcha_img']; ?><br /><br />
<input maxlength="10" size="10" class="chrono_captcha_input validate['required']" title="" type="text" value="" name="chrono_verification" /> <?php echo $form->data['chronocaptcha_refresh']; ?>
</div>


Solved!
This topic is locked and no more replies can be posted.