FormBoss 2 Documentation
Top Link
Text File Upload

In Brief: Form users can upload file's through your form.

Dependencies: none.

Hints & Tricks: You can easily send file upload items to a Email module for attachment. To do so, you simply need to check the Send to Database / Temporary Storage checkbox for that file item.

Options/Properties

Basic Attributes

Label
Type the text you want to appear above or to the side of the form element. This is also the value of the text displayed in the FormBoss Result Browser and Email messages.

The label field supports local PHP variables if they are wrapped in PHP tags and echo'd out as: <?php echo $val; ?>

Please note that only local variables are supported, $_SESSION variables must be bound to local variables in the PHP Top Code or PHP Head Code section first.

As of Build 693 the functionality of this item has been expanded to support dynamic tokens for E-Commerce items. Please see the in-editor tooltip (located just above this field), for specifics.

As of Build 701, this field now also accepts the standard FormBoss 2 token set for form field labels. Please see the in-app tooltip for exact values to use.

As of Build 705, this field now accepts the standard FormBoss 2 token set for Section/Headline Text and Body Copy elements. That is, we used to only be able to use the @{value} token, as can now use F{}, S{} and so on.

The 'new' tokens will, by default, transform linebreaks into HTML br tags. This is very handy when we want to display a text area to a user where such line breaks have been added. This ensures the typed value matches, as closely as possible, the display.

Also in Build 705 is the 'raw' field token: FR{field_name}. This token was created because by default, when we use a F{} token for say, text1, we are actually creating the following code:

<?php if(isset($_SESSION['qs']["{$_SESSION['entry_key']}"]['text1'])) { echo "{$_SESSION['qs']["{$_SESSION['entry_key']}"]['text1']}"; }?>

That is, a full (but inline) PHP block. This makes it impossible to create custom logic in a Body Copy or Section Text block, as the open and close PHP blocks break any such custom code.

Thus, the raw token only places the raw field value into the text data, nothing more. The same text1 item now looks like:

$_SESSION['qs']["{$_SESSION['entry_key']}"]['text1']

That is, no PHP block, and no isset().This means we could, for example, create the following logic in a Body Copy element:

<?php
if(isset(FR{text1}) && FR{text1} != "") { ?>
I want to hide this Bodycopy if @{text1} is empty ?
<?php } ?>

Name/Value
This element is set by FormBoss automatically, though it is recommended to change this value if you decide to display Javascript validation messages, as the 'identifying' text of the error is the value of this field.

This value is displayed by default if no 'Label' attribute is assigned to the element. For technical users, this element name is in fact the same as the Name/Value html form attribute of this element.

You will also notice that if you change the name of this field, the id attribute to the immediate right of this element also updates with the same value. This is because in most cases you should keep the same value for both elements--however, you can use a different value, simply type in the id field separately.

Naming Convention Note: The only valid punctuation for the Name/Value and id fields is the underscore _. Use of any other character will cause the form to fail.

This is an incredibly important item for the Email+ and SQL+ Modules. The value you type into this box is what you will use to retrieve the dynamic value of the field at runtime. This element is often referred to as {field_id} in the documentation of those modules


id
By default is assigned the same value as the Name/Value element, though you can change this to a more field specific value. Not necessary for most applications. For technical users, this is the id attribute of the field item.

Helper Text
This text displays on the bottom of the field item. By default, the text is 7pt and light grey #888888. You can change the elements color in the FormBoss editor, but the font size must be changed in the jobs formpage.css file.

Default Value
[Only used with text element such as text box and text area]
Any pre-assigned values for this element should be typed into this box. At run-time this value is automatically populated into the field item.

You can use PHP variable names in this field, simply include the variable name enclosed in braces as in: {$random_variable}

There are a few special considerations with using PHP variables in this field:

1. Always wrap the full variable in braces.

2. You cannot execute functions in this block, only variables.

3. $_SESSION variables must use single quotes as in {$_SESSION['variable']}, not double quotes as in {$_SESSION["variable"]}

4. All variables are passed through htmlentities($variable, ENT_COMPAT), which means any double quotes are turned into &quot;

Field Width
In pixels units, the height of the field item. Default of 140 for text boxes and 200 for text areas.

Field Height
In pixels, the width of the field item. Default of 70.

TinyMCE Editor
[Text area only]
Adds a TinyMCE Rich Text Editor to the text area.

Select from three TinyMCE preset configurations:
Simple Editor - Provides basic text controls.
Text Heavy - Provides ~13 text editing tools plus a slew of editing control such as undo.
FromBoss Style - Creates the same suit of text editing tools used in the FormBoss Editor.

* Please be aware that at this time the Display Field Count validation property has no effect on text areas that use TinyMCE. You can still set a maximum character count, but this value will only be validated at the time of the forms submission via PHP, not JavaScript.

** You can only use 1 style of TinyMCE text editor per form page. The text area that comes first in the form will determine which TinyMCE text editor configuration is used.

Wrapper Class Name
Every field element in FormBoss is wrapped in either a LI or DIV element for Sortable or Free Form page types, respectively. When you place a value in this box it becomes the class="" attribute for that wrapper. Because a wrapper encompass both the input element and wrapper, you can use this value to show and hide sections of your form.

Extra Attribute(s) JS Etc - Formerly known as [ Extra Attribute(s) JS Style Etc ]
Although similar to a submit button, a button has an html type of 'button', not type=submit, which means when this element is clicked on, your form will not be submitted, but rather you must supply the event to occur.

A common use of this type of element would be to attach a history command such as onclick="history.back()", and then use it on a multi-form page to make navigating back one page easier than using text links.

Add code to your field item by typing it into this box. Code can be JavaScript event code such as:
onclick="alert('Be sure to use Letters only');"

External Library dependent code as in: (Prototype/Scriptaculous example)
onclick="Effect.Fade(this, { duration:.2});"

What's important to note is that the code you create here effects the field element, not the container it sits in. To edit the field container, you need to reference the field name prefixed with 'fb_fld-', as in a text box with an ID of text1 would be referenced like:
fb_fld-text1

Extra Input Field Style Attributes
New to Build 683, this field allows us to define extra style attributes for our form elements such as:

Or Style definitions as in:
style="color:#cdcdcd;"

It is important to note that in older versions of FormBoss we would have applied styles to the Extra Attribute(s) JS Etc field.

Finally, it is also important to consider that FormBoss also applies style data, traditionally as:

font-size:12px; color:#444444; font-family:inherit; width:200px; height:70px;

In short, font properties and height/width are handled automatically via editor properties.

Conditional Processing

Field Initially Visible?
Determines if the form element is visible when the page first loads. Please note that this logic always resets on page load, that is, if a user goes back one page where an element was previously shown it will be invisible again.

Easy Toggle?
Checking this box means FormBoss will automatically handle the logic needed to perform the opposite action you set in Then... and If This Field Is: properties. For example, if you set the action of an item to be 'Show', if the condition needed to make this show acton happen is revoked, the opposite action will automatically happen for you. So, if the condition is the text '1' must be set in a text box in order to show a second text field, if this 1 is removed or changed, the second text box will be hidden again.

In general we want to keep this box checked, though if you wanted to force a field to always show after an action then leave it unchecked.

Field Validation Method
New in Build 717, this option allows us to set the behavior of how conditional items will be validated when hidden.

By default, when we set an item to be hidden and required FormBoss will still process the invisible item as if it were shown to the user. With this new option we can override this behavior to tell FormBoss that any item that's hidden and set with Field Only Validates When Visible should, as the option name states, only trigger validation errors when visible.

The trick with this is from a security standpoint it's possible to create a script that exploits this behavior such that no fields would be required. However, the FormBoss implementation is such that only fields set with the property are able to be 'bypassed' via normal validation methods.

The end result then is if we're building a form that needs to have required fields, but those fields are hidden unless a user triggers a condition to show them, to enable this mode for that field, and of course any others that require it.

By default FormBoss will still validate all fields unless told otherwise. This maximized security while providing a way to create smarter forms.

Event Trigger
This is the JavaScript event that will be scanned for and then acted upon if activated. Some events are better than others for the various tasks you have. For example, the onClick event is perfect for Checkboxes, whereas the onKeyUp event is perfect for text boxes where a user needs to enter a specific value. Experiment with these values and have fun!

Caution! You may run into a situation where you build a form that enables the event trigger on a specific field, then remove that field later on without updating the Event Trigger's 'binding' to that element.

If this happens your forms validation will break, along with other potential issues.

The solution is always make sure that when we enable an event trigger for an element, that field exists on the form.

Animation?
While not always needed, if you want you can add animation using Prototype JS to your events. The upside of this is your forms may have a more professional appearance, the downside is the extra bandwidth needed to send the Prototype JS library over the wire to run the animations. However, if you are already using animation or have included the Prototype JS library for other purposes, this bandwidth cost is obviously negated, so animate away!

If This Field Is:
This is the core property of the Conditional Processing logic. In most cases you will only want to show and hide fields if a specific condition is met, this option allows us to set that condition. As with the Event Trigger property, some options only make sense in the proper context. For example, the top Value Comparison grouping is best served in combination with text and select fields, whereas the Field State options of Checked and Unchecked only make sense for checkboxes.

It is also important to note that FormBoss will attempt to cast comparison values set as INT and FLOAT values to their respective native types.

This Value...
When we set the If This Field is property, with the exception of the two Field State checks of Checked and unchecked, we typically want to compare against some value. It is in this text box that we set that comparison value. FormBoss will automatically attempt to detect FLOAT and INT values when testing against GREATER THAN and LESS THAN checks.

Then:
If the condition set in If This Field Is and This Value... passes, this is the action we will perform. Please note that is Easy Toggle? is enabled, we will automatically perform the opposite when the check fails.

This Field Or...
When we set an event, comparison, and action, the last step is to tell FormBoss which fields to act upon. It is in this field and is close relative, This Wrapper Class, that we set this field or fields.

As you build your form FormBoss will automatically track the Name/Value properties of the elements on that form page and then present them to you in list format in this field. Thus, all eligible form fields will be displayed in this select item, the one you select will become the field acted upon.

Finally, any elements that are set to hidden on page load are tagged with a [H], which makes it easy in many cases to see which items you may need to work with.

This Wrapper Class
Similar to the This Field Or... property, with the exception that instead of single field we can act upon all elements with the same Wrapper Class attribute. This makes it very easy to show and hide large portions of content with one action, perfect for address fields and the like.

Custom Conditional Field Statement
Although FormBoss tires to automate as much of the show/hide process as possible, their will be times when you need to have more complex logic. When this is the case, we can use the simple FormBoss API to create custom logic.

The bulk of this logic will be derived from a JavaScript object called fbc, which stands for FormBoss Conditional. This object is defined in:

/formboss-root/app/movefiles/conditional.js

Which is exported into the root of all FormBoss jobs.

The basic usage of this object will depend on what action you want to perform. That said, their are 4 methods you need to know about:

hideField, hideWrapper, showField, showWrapper

As shown in the editor, we call these methods as:

fbc.showField(event, 'FieldName', 'animation');

With a simple example to show a text box being:

if(value == '1'){
  fbc.showField(event, 'text2'); // animation argument is optional, event is not!
}

Simple enough--But it is important to understand that at the page code level FormBoss creates two distinct but related items.

The first is the event trigger which is placed inline with your form element. Please be aware the event used is not created automatically, you need to select one from the Event Trigger select item.

Thus, if we select the onKeyUp event FormBoss will place this code inline with your element:

onkeyup="fb_dyn_text1(event, this.value, this)"

Notice we have three arguments. This is important because the inline method call is directlly tied to the second main element FormBoss creates for you, which is a script tag with that methods definition.

This method looks like:

function fb_dyn_text1(event, value, elt){
  if(value == '1'){
     fbc.showField(event, 'text2');
  }
}

As you may now see, this method body is the code you create in the Custom Conditional Field Statement text area. The reason why it is wrapped in the method is to that you do not need to worry about creating or gathering the event, value, and elt parameters.

Thus, the last bit of knowlegde to convey is that these paramters, event, value, and elt, can be used in any way you need in your Custom Conditional Code. Most of the time you will only need the value parameter for your logic, but please notice you must pass event to the fbc functions no matter what.

Callbacks
New in Build 711, we now have a callback that's fired after an animation plays:

animationDone(elt)

We use this callback inline with our Conditional Code block as in:

fbc.animationDone = function(elt){
  alert(elt.id);
  // when animation is done, call resize function for iframe
  window.parent.resizeSubForm(getOutputSize());
}

That is, we call fbc.animationDone(elt), then in that function, define the actions to take place.

The elt parameter is the object that called the animation, that is, is the object which reacted to the event.

Please note this event is fired for every animation that plays. Thus, if we've used this in the content of a Wrapper Class with say, 5 elements, this function is called 5 times.

Field Style Properties

Element z-index
New to Build 697, this feature allows us to set the z-index of most items. This property is reflected in the editor as well, making positioning items much more streamlines than in previous versions.

By default most items, with the exception of calendar fields, have a base index of 1. This means so long as your form fields to not overlap you will not need to set this property. However, some fields, such as images or those with popup's (like the calendar field), benefit from setting a different layering order.

Text Color
Click into the box to load the color selector. Drag your cursor over the saturation in the main box to select the color intensity, or drag the hue slider to change color.

Input Text Color
New to FormBoss 2, this field lets you set the input fields color.

Font Size(px)
Type a number in this box to change the font size of the element.

Label Font Weight
New to Build 685, this option lets us set the font weight of the forms field label or main text block.

Field Spans Both Columns In Table Layout
New to build 704, when enabled this option lets the form element in question span both columns in a tablemode layout.

Notes: As of now the only fields to use this option are Section Text, Body Copy, Images, and Separators.

Label Position
Has no effect for this field. Might be implemented in later versions.

Input Inherits Font Size and Family
New to FormBoss 2, this field lets you set the input elements input font and size to match the label field.

Validation

It is very important to note that validation behavior is handled in two places: the field itself, and in the fields containing page properties. Within the field, you can control the elements listed below, such as weather the field is required, the minimum and maximum number of characters, and so on. Within the page properties, you control the style of error, weather messages are displayed, and other such properties. One way to think of it is error handling per field item, and global error handling properties. FIeld item properties are specific to that element, global effects all error properties of that page.

For example, the default behavior of a field that is marked as required is to, when filled in improperly, highlight the field with a color you choose in the Page Properties Form Error Color. In other words, you set the field as required in the elements field properties, but you control the color of the error highlight in page properties.

For more information on what properties you can edit, please see the Form Style Properties and Page Properties of the Sortable and Fee-Form Page types.

Required
Check this box to make this field a requirement for successful form submission.

Required Star Color: In some instances you will want to change the color of the required star. To do so you can use one of two techniques:

Technique 1. Permanent change: Navigate to the formboss/app/movefiles/ folder and open the formpage.css file and look for the .req-star class definition. You can then change this color to fit your jobs needs. This change is permanent because every job you export will now use this style sheet file and definition.

Technique 2. Per Job Change: Click on the page header to bring up that page's attributes, then add the following style definition to the Page Javascript/Head Code code area:

<style type="text/css">
  .req-star { color:#dedede; }
</style>

This will override the style definition in the formboss.css file and use the color you specify.

Min
The minimum number of characters this field must possess. Validates if the field is required or not.

New in Build 706, for checkboxes, this is the minimum number of items that must be checked for the field to be valid. To set a specific number, set the min and max values to the same value.

Max
The maximum number of characters this field can contain. Validates if the field is required or not. If you wish to limit the number of characters a user can type, specify that value in this field. The user will not be able to enter more characters specified by that value.

For checkboxes, this is the maximum number of items that can be checked.

Regex Validation Rule

This is the Regular Expression rule to apply to this field. Used in required fields only. Choose from No Rule, Custom Rule, and a series of preset rules.

If you choose Custom Rule, you will be given a 'Custom Regex' box to populate with your own expression (please note only one expression can run on each element).

For example, you could use this to validate $45.23:

^\$[0-9]+(\.[0-9][0-9])?$

or without the dollar sign as in 45.23:

^[0-9]+(\.[0-9][0-9])?$

Same As
[Only used for Text and password fields] If populated, this element and the one specified must match to validate. Only effective if the field is required (the must match field need not be specified as required). Effective for user password and email address validation.

Validation Error Message
Type a custom message for validation here, in the event you select a 'Regex Rule' for the field. All other validation messages are handled by FormBoss.

Display Count Fields
[Only used for textarea elements] Select from No Counting, Words, or Characters. Select Words or Characters to display a Javascript based character/word counter at the base of your text area element. This item works in conjunction with the Max validation field, though if no value is set it defaults to 500 characters.

File Uploads

Maximum File Upload Size
Select the maximum file upload size you wish for this field. Choosing 'Server Maximum' will let FormBoss query your PHP .ini upload_max_filesize for this value.

Please note that as of Build 693 we now display this and the post_max_size property value as currently set on the server. This is important because while we may provide a large enough value for each file upload via upload_max_filesize, the post_max_size property determines the total page data for the POST request, which if smaller than the total size of all page elements (including form fields and file upload slots), the upload will fail.

Thus, the simple rule is post_max_size should always be big enough to handle every upload on the page, as well as all form fields.

Both of these settings are found in your servers php.ini file. Because of this, any changes you need to make to these settings are best handled by contacting your web hosting provider.

Allowed File Types
All files will not distinguish between images and non-images, however, in the FormBoss Result Browser all fields designated with this value will appear as file downloads.

All Files
All file types will be allowed.

Images Only
will check to make sure the uploaded file is on mime type's: pjpeg/jpeg/gif/png/wbmp

Files Only
Will prevent image files from being uploaded, makes sure no image mime types are passed through.

PDF Files Only
Will do a MIME check for PDF files and attempt to block all others.

Save As A Flat File?
If checked, FormBoss will save a copy of the uploaded file to your file system. Please note FormBoss will automatically rename duplicate files, appending a dash (-) and the increment number to each file.

Please also note that if a file rename does occur, the SQL+ meta field _name will contain this new name, which means your database record and flat file system will remain in sync.

See Flat File Directory below for more information on where your flat files can and will be saved too.

Send To Database?
If checked, a copy of the file will be sent to the FormBoss database (if using a database module such as Simple SQL) and temporary storage (basically a session variable). This will only work if you have a unique jobname set.

IMPORTANT: If you want to have files sent as email attachments you need to have this box checked for each item you want attached. Please see Confirmation Elements -> Email and Email+ for more information on this topic.

One very important rule you must follow when using this feature: Because this feature uses the FormBoss database, you must be sure to a) be using a local copy of FormBoss so you have access to the FormBoss database tables or b) if this job is destined for another server without the FormBoss database, you'll need to install the FormBoss Entry Viewer Standalone on that server.

Make Available As Email Attachment?
New to Build 670, this is more of a refinement than a new feature. When checked, this item will be included in the list of files that can be attachments for your email items (modules). We say can be because in order to have this file become an attachment to that email, we also need to make sure to check the 'Include file attachments?' option of the email confirmation item. The reason we do this is because it gives us an incredible amount of control over what gets attached in our forms. We can set an item to only get sent to the database, only get prepped as an email attachment, or any combination of the two that fits our jobs requirements..

Flat File Directory
If sending items to flat file, this will be the name of the directory used to save the files in. Defaults to 'upload', but any value you enter here will override this default value.

Please be aware that you only need to use the directory name if you want the file to be saved in the same directory as the job, for example, images would create and use a folder called /images. In other words, you do not need to add any slashes. However, a ./ will mean "current directory", a ../ means go up one directory, and so on. In any event, please keep in mind the root directory is the current jobs directory.

Max Image Width / Max Image Height
If set, all image's uploaded will be scaled down to this value if over. Values are in pixels.

Create Thumbnail?
Check this box to create thumbnails of uploaded images. Please note that thumbnails are created as flat-file and database-ready elements via the shortcut:

file_field_name_thumb

That is, the Name/Value of the file upload element, an underscore, and the word thumb. Please see SQL+ Integration for more details on using these shortcuts.

All thumbnails will be created using the naming convention thumb_{original_file_name}.xxx, and stored in the file upload directory of its parent job folder.

!IMPORTANT! Thumbnails are only created when Allowed File Types is set to Images Only.

Max Thumbnail Size
This is the maximum dimension in pixels you want the thumbnail to be. The widest dimension determines which axis the image will be scaled down in. For example, an images that is wider than it is tall will be scaled down by width.

Thumbnail Directory
Specify the directory you would like to have your thumbnails saved too. This can be as simple as thumb_images, which would create (if it doesn't already exist) a directory called thumb_images in that jobs folder and save all thumbs to that directory.

Please notice that you do not need to add a slash to the name if you want it saved in the same directory. You would however, need to use appropriate path nomenclature to save in other parts of your server, so long as you have permission to. For example, you could save one directory up with ../thumb_images.

DB Connector File
If you input an absolute path into this box, FormBoss will use that file for all database connection information for this query.

SQL+ Integration
FormBoss supports a variety of SQL+ enhancements to the File Field item. For more information on SQL+ items, please expand the Confirmation Elements section and click on the SQL+ icon.

For starters, all file upload fields are referenced with the same technique as any other field, that is, the field id inserted into a SQL+ statement will transfer that file upload item to your database per your SQL+ insert statement.

Second, all file fields are automatically tagged with three meta tags plus an optional _thumb data item for images:
_name
_mime
_size
_thumb (Image uploads only!)


These meta names are accessed in SQL+ insert statements by prefixing the _ meta name with the field id of that item. For example, a field called image could be used in an SQL plus statement in the following way. (This example assumes you have created a file upload field and assigned the item with an id of 'image', and also created a table on your database named 'result'):

SQL+ Code:
INSERT INTO result (image, image_name, image_mime, image_size) VALUES (?,?,?,?)

Variables:
image,image_name,image_mime,image_size

As you can see, the image field is the only item we have actually created in FormBoss, the other three elements are created by FormBoss, you just need to reference the meta values correctly to insert their values into your table.

As stated above, we also have one more meta item: _thumb. This field is only available to us if we have selected 'Image' from the Allowed File Type drop-down menu. To use this field, you would simply expand the query above to include the _thumb meta item:

SQL+ Code:
INSERT INTO result (image, image_thumb, image_name, image_mime, image_size) VALUES (?,?,?,?)

Variables:
image,image_thumb,image_name,image_mime,image_size

As you can see, by prefixing _thumb with the file upload field id, which in this case is image, we will upload the image to our database on form submission.

Flatfile Integration
Similar to the SQL+ integration, when using the FlatFile module to save data out to a file on your file system, you can use the following meta fields as a prefix to the field name:

_name
_mime
_size

For example, if you had a file element called file, you could retrieve the uploaded files mime type with:

file_mime

Builder Page Integration
You can build a form that saves flat files and then loads those flat files in a Builder Repeater page.

Assuming a file Name/Value of file_1, The most common technique for this would be to set your Flat File Directory to a folder one level up from the form with:

../upload_images

Then in the SQL+ Module, set the file column to the name of the file with:

INSERT INTO entries (file1_name) VALUES (?)

And this for variable values (this is a meta query, described above in SQL+ Integration):

file_1_name

And then in your Builder Repeater, create an image item, and set the fully qualified link to the file1_name database field with this as the images path:

http://domain.com/formboss/output/forms/standings/#{file1_name}

Thus, you would now have images being uploaded to your server file system, a record of the file name in the database, and in the Builder Repeater token, a link between those two items in the form of the image link which looks in the folder of images for the image name saved in the file1_name database column.

top