Page 1 of 1

Custom FormBuilder template [solved]

Posted: Tue Sep 01, 2015 3:18 pm
by douglas1438
With help from this forum I've successfully been using custom templates in FormBuilder so they integrate with Bootstrap.

http://forum.cmsmadesimple.org/viewtopi ... =7&t=71995

Up until now they've been simple forms with text inputs, I now need to add a date of birth field, with dropdowns for day, month and year. Along with a set of check boxes.

Can anyone tell me how I adapt the code below to reference these?

Current code for text input.

Code: Select all

<div class="form-group">
<label for="{$actionid}{$name->input_id}">Name</label>
<input class="form-control" type="text" name="{$actionid}{$name->input_id}" id="{$actionid}{$name->input_id}" title="Please enter your name" required="required"/>
</div>

Thank you.

Re: Custom FormBuilder template

Posted: Tue Sep 08, 2015 6:14 pm
by Dr.CSS
You're going to have to explain this in a little more detail than that...

Re: Custom FormBuilder template

Posted: Wed Sep 09, 2015 9:00 am
by douglas1438
Please see my more recent post

http://forum.cmsmadesimple.org/viewtopi ... =7&t=73428

Unfortunately can't delete this one.

Thank you,
Chris

Re: Custom FormBuilder template

Posted: Mon Dec 07, 2015 11:19 am
by douglas1438
Despite upsetting Jeff (for which I apologise) and spending countless hours playing with loops I'm still struggling to resolve this.

For someone with better Smarty knowledge than me I'm sure the solution must be very simple. I'm building a form template in formBuilder by calling each field individually.

Calling text fields works without problem:

Code: Select all

<input class="form-control" type="text" name="{$actionid}{$name->input_id}" id="{$actionid}{$name->input_id}" title="Enter your name" required="required" />
Also works for a date of birth set of dropdowns.

Code: Select all

<label for="{$actionid}{$dob_day->input_id}">Day</label>{$dob_day->input}
<label for="{$actionid}{$dob_month->input_id}">Month</label>{$dob_month->input}
<label for="{$actionid}{$year->input_id}">Year</label>{$year->input}
My problem is radio buttons, I know they are in an array but I can't come up with a foreach statement to pull them out, if I use {$test_radio|@print_r} I get the following:

Image

As you can see from the screen capture it is showing the radio button, i just can't work out how to reference it.

Could someone please tell me how I can display the group of radio buttons, with their values and labels in my template please?

Thank you,
Chris

Re: Custom FormBuilder template

Posted: Mon Dec 07, 2015 3:22 pm
by velden
Something like (untested):

Code: Select all

{foreach from=$test_radio->input item=radiobutton}
  name: {$radiobutton->name}<br>
  title: {$radiobutton->title}<br>
  input (code): {$radiobutton->input|cms_escape}<br>
  input: input: {$radiobutton->input}<br>
{/foreach}

Re: Custom FormBuilder template [solved]

Posted: Thu Dec 10, 2015 10:40 am
by douglas1438
Thank you so much velden that works perfectly.

Chris