 a form builder is a regular request for some clients when they are looking for a content management system there arent that many cms that have this kind of functionality built in and even if they do the implementation is usually less than desirable if you follow along with what ive been up to you can probably tell that i have been on a big expressionengine kick ive been using it on a ton of projects recently and i love it for its flexibility although it does lack a true form builder i figured out a simple way to build one if you are impatient and just want to get to the demo go ahead although the form will look like nothing special as i have just added some simple styling the real magic of the form builder happens in the control panel we need add ons this form builder would not be possible without the use of some awesome add ons fieldframe this one is a no brainer i cant even imagine building a site without it freeform if you need a form in ee this is the way to do it freeform data select a new fieldtype which pulls in templates and fields from the freeform module creating a field group i built a custom field group called forms which consisted of four fields template notification email addresses return page fields the first three are pretty simple so i will just give a quick run through on the specifications for those fields and give a more detail review of the fields field template this is where you select the freeform template that will be used for the email this field is not completely necessary as just using the default template should be good enough but i figured since it was an option to throw it in field name form template field type freeform data select populate drop down with freeform templates notification email addresses this is where you will enter the email address es that you want to email when the form is submitted since freeform wants multiple email addresses separated by the character i added some help text describing that as well field name form notify field type text input default text formatting for this field none hide formatting menu return page this is where you enter the url to the thank you page once a user successfully submits the form they will be redirected here field name form return field type text input default text formatting for this field none hide formatting menu fields this is where the magic happens this field is a ff matrix field type that consists of five other fields each row of the ff matrix represents one field or field group in the form ill give a brief description of each field of the ff matrix and show you a screenshot so you can get a better picture field name form field field type ff matrix label this is where you will enter the label for the form field col name label cell type text input field this field pulls in all of the fields that have been entered into the freeform module so you are presented with a dropdown of all of the fields and you just select the appropriate one col name field cell type freeform data select populate drop down with freeform fields field type this is where you select the type of form field you want to use i put in a few different options but this could be expanded upon too col name type cell type ff select select options text input textarea select multi select checkbox checkbox group radio group is this field required with most forms there are some fields that are required and some that are not if you want the field to be required you just check the checkbox and the freeform module will make sure it is filled in col name required cell type ff checkbox checkbox label is this field required options finally this field is used when you select a field type that has multiple options for example if you select a select field type you need to provide the options to populate it so you enter the options separated by the character col name options cell type text input so that is all you need for the field group now go ahead and create a forms channel or weblog and make sure to assign the forms field group to it now when you go to publish a forms entry you should see something like this i made a demo form showing off the various types of form fields here is what that entry looks like in the control panel template now that we have our channel and field group all setup we need to deal with the template you could really setup your template template group in various ways so im not going to get into those details one detail that you need to know is that i enabled php for my template first we just need to start with a simple exp weblog entries tag exp weblog entries weblog= forms limit= 1 disable= categories category fields member data pagination trackbacks exp weblog entries next we want to start the freeform form tag exp weblog entries weblog= forms limit= 1 disable= categories category fields member data pagination trackbacks exp freeform form form name= url title form id= url title template= form template notify= form notify return= form return exp freeform form exp weblog entries since we are inside of the exp weblog entries tag we have access to everything that is being returned from that entry if you have any questions about the various parameters refer to the freeform documentation so far the values that we are passing into the parameters are pretty straightforward just custom fields from our entry but passing in the required parameter is a little more challenging since we have to loop through all of the rows in our ff matrix if we refer to the ff matrix documentation we can see how to loop through the rows in the matrix i only want to return rows that have the required checkbox checked and i want to separate the names of the fields with the character then i use the backspace parameter to remove the last one exp freeform form form name= url title form id= url title template= form template notify= form notify return= form return strongrequired= form field search required=y backspace=1 field form field strong exp freeform form next we want to add a title ordered list that will contain the form fields and the submit button exp freeform form form name= url title form id= url title template= form template notify= form notify return= form return required= form field search required=y backspace=1 field form field h1 title h1 ol class= forms li class= buttons input type= submit name= submit value= submit li ol exp freeform form now here is where the code gets interesting just like we did with the required parameter we want to loop through each row in the ff matrix and display a list item for each one form field li li form field first lets display the label if there is one and denote if the field is required or not if label label for= field if required == y em class= required em if label label if the rest of the code is a big conditional statement which depends upon the field types that you specified in the ff matrix lets first take a look at the text input textarea and checkbox types since they are pretty straightforward if type == text input input type= text name= field id= field if elseif type == textarea textarea name= field id= field textarea if elseif type == checkbox input type= checkbox class= checkbox name= field id= field if so we are just checking the type column in the ff matrix and then displaying the rest of the data from the row in the appropriate form field next lets walk through what happens if you select the select or multi select types if elseif type == select type == multi select options select name= field if type == multi select if id= field if type == multi select multiple= multiple size= 4 if php $items = explode options php foreach $items as $item option value= php echo $item php echo $item option php select if so first we are displaying the select element and if it is a multi select we are adding to the name attribute and adding the multiple and size attributes next we want to take the string of options that are separated by the character and create an array out of the string using the explode function then we loop through the array and display the options for each one finally we do virtually the same thing for the radio group and checkbox group field types if elseif type == radio group options ul class= group php $items = explode options $count = 1 php foreach $items as $item liinput type= radio class= radio name= field id= field php echo $count value= php echo $item label for= field php echo $count php echo $item label li php $count php ul if elseif type == checkbox group options ul class= group php $items = explode options $count = 1 php foreach $items as $item liinput type= checkbox class= checkbox name= field id= field php echo $count value= php echo $item label for= field php echo $count php echo $item label li php $count php ul if so thats it really here is the full template exp weblog entries weblog= forms limit= 1 disable= categories category fields member data pagination trackbacks exp freeform form form name= url title form id= url title template= form template notify= form notify return= form return required= form field search required=y backspace=1 field form field h1 title h1 ol class= forms form field li if label label for= field if required == y em class= required em if label label if if type == text input input type= text name= field id= field if elseif type == textarea textarea name= field id= field textarea if elseif type == checkbox input type= checkbox class= checkbox name= field id= field if elseif type == select type == multi select options select name= field if type == multi select if id= field if type == multi select multiple= multiple size= 4 if php $items = explode options php foreach $items as $item option value= php echo $item php echo $item option php select if elseif type == radio group options ul class= group php $items = explode options $count = 1 php foreach $items as $item liinput type= radio class= radio name= field id= field php echo $count value= php echo $item label for= field php echo $count php echo $item label li php $count php ul if elseif type == checkbox group options ul class= group php $items = explode options $count = 1 php foreach $items as $item liinput type= checkbox class= checkbox name= field id= field php echo $count value= php echo $item label for= field php echo $count php echo $item label li php $count php ul if li form field li class= buttons input type= submit name= submit value= submit li ol exp freeform form exp weblog entries conclusion this is not meant to be an all inclusive form builder as you can see there are many other parameters for the freeform module but this was meant to show a creative use of expressionengine and ee add ons to add functionality that is not directly built into the cms so go forth and create 