Formbuilder question...
Posted: Wed Nov 24, 2010 3:43 pm
Hopefully just a quick one... I know you can pass in variables to be assign to certain field values when calling form builder via the module tag, eg:
However, I'm working with a really big form, and it's quite a fiddly layout and so the easiest way for me to put it together was to create the form in form builder, copy the resulting source, and then build the form via a combination of form builder tags in the template, and hard coded inputs etc. I know it sounds a bit random but it really is a mental layout and this is the only way I can get it looking right!
Here's an example of some of it (I've only included a few fields because the full thing is massive, like a hundred fields!)
The long and short of it is that it's working fine, but the fields don't retain their values if the submission fails validation (no value parameter in the above example at all), so I'm hunting around for a variable that's generated on submission of the form and passed in that I can use in the manually created fields.
I've done a {get_template_vars} and found objects for each of my form fields, and done a print_r on a few of them. I was hoping that the {$my_field->values} object variable might give what I'm after, but it seems that the previously entered value is just added to the {$my_field->input} html string, which I'm not using on a lot of my fields as they are hard coded... is there anyway I can get at the value or do I just have to bite the bullet and use the input variable of each field to generate my html?
Code: Select all
{cms_module module='FormBuilder' form='myform' value_fld1=$myVar}
Here's an example of some of it (I've only included a few fields because the full thing is massive, like a hundred fields!)
Code: Select all
<div class="feedback">
{$fb_form_header}
{if $fb_form_done == 1}
{* This first section is for displaying submission errors *}
{if isset($fb_submission_error) && $fb_submission_error}
<div class="error_message">{$fb_submission_error}</div>
{if isset($fb_show_submission_errors) && $fb_show_submission_errors}
<div>
{foreach from=$fb_submission_error_list item=thisErr}
<span class="error">{$thisErr}</span>
{/foreach}
<br />
</div>
{/if}
{/if}
{else}
{if $fb_form_has_validation_errors}
<div>
{foreach from=$fb_form_validation_errors item=thisErr}
<span class="error">{$thisErr}</span>
{/foreach}
<br />
</div>
{/if}
{if $captcha_error}
<div>
<span class="error">You did not correctly enter the characters in the image. Please try again.</span>
<br />
</div>
{/if}
{$fb_form_start}
{$fb_hidden}
<fieldset>
<legend>Send us a message</legend>
<p>(You have to enter something in the fields marked with a '*')</p>
<div class="input-field">
<label class="main-label">Your Name *:</label>
<input name="cntnt01fbrp__14" class="textfield med" type="text">
</div>
{*hundreds more fields here*}
<div class="input-field">
<label class="main-label">Please enter the characters you see in the 'captcha' image below *</label>
{$graphic_captcha}
<input class="textfield small" name="cntnt01fbrp_captcha_phrase" id="cntnt01fbrp_captcha_phrase" value="" maxlength="255" type="text">
<p>(This helps prevent spam email, and so allows us to respond to your message sooner.) </p>
</div>
<div class="input-field">
{$submit}
</div>
</fieldset>
{/if}
{$fb_form_end}
{$fb_form_footer}
I've done a {get_template_vars} and found objects for each of my form fields, and done a print_r on a few of them. I was hoping that the {$my_field->values} object variable might give what I'm after, but it seems that the previously entered value is just added to the {$my_field->input} html string, which I'm not using on a lot of my fields as they are hard coded... is there anyway I can get at the value or do I just have to bite the bullet and use the input variable of each field to generate my html?