SproutCMS

This is the code documentation for the SproutCMS project

Page options:

Inherited members

class Fb

Quick and easy form builder

Variables

NameVisibilityDescription
$data (static) 
$dropdown_top (static) 
$field_id (static)
ID for use on the field label and input/select/etc. element
$id_prefix (static) 
$include_class (static)
Extra class(es) for use on div.field-wrapper, div.label, and div.field to support additional styling.
N.B. If this is set, all inputs will be wrapper in a div.field
$scope (static) 

Functions

NameVisibilityDescription
addAttrprotected (static)Adds an HTML attribute to the list of attributes.
autoCompleteAddresspublic (static)Renders google autocomplete address fields
autocompletepublic (static)Returns HTML for an autocomplete selection menu.
autocompleteListpublic (static)Render autocomplete multi-list
checkboxprotected (static)Returns the HTML for a single checkbox
checkboxBoolListpublic (static)Returns HTML containing multiple boolean checkboxes
checkboxSetpublic (static)Returns HTML containing multiple checkboxes, with values to store in a SET column or similar
chunkedUploadpublic (static)Generates a file upload field with a progress bar
colorpickerpublic (static)Renders a colour picker
conditionsListpublic (static)A conditions list, which is an interface for building rules for
datepickerpublic (static)Renders HTML containing a date selection UI. Output field value is in YYYY-MM-DD
daterangepickerpublic (static)Renders a date range picker. Output is in the form of two fields (given in name as a comma separated list) e.g.
datetimepickerpublic (static)Renders HTML containing a date-time selection UI. Output field value is in YYYY-MM-DD HH:MM:SS
datetimerangepickerpublic (static)Renders a datetime range picker
dropdownpublic (static)Generates a dropdown selection menu
dropdownItemspublic (static)Returns HTML for a list of OPTIONs, and depending on the input array, OPTGROUP tags.
dropdownTreepublic (static)Generates a dropdown selection menu from a Treenode and its children
dropdownTreeItemprivate (static)Used internally for recursive dropdown generation.
emailpublic (static)Renders a HTML5 email field
fileSelectorpublic (static)A file selection field, for use in the admin only.
genIdprivate (static)Generate a unique id
geocodeAddresspublic (static)Renders place name geocoding fields
getDatapublic (static)Gets the data for a single field from the data array
googleMappublic (static)Render map location selector
headingpublic (static)Generates a heading using a H3 tag
hiddenFieldspublic (static)Renders a set of hidden fields
injectIdprotected (static)Injects the current auto-generated id into an array of attributes.
inputpublic (static)Generates an HTML INPUT tag using Fb::tag, with auto-determined value
lnkpublic (static)Render the UI for our multi-type link fields
moneypublic (static)Shows a HTML5 number field, formatted for dollar prices
multilinepublic (static)Generates a multiline text field
multipleFileSelectpublic (static)UI for selecting or drag-and-drop uploading one or more files.
multiradiopublic (static)Returns HTML for a bunch of radiobuttons
numberpublic (static)Shows a HTML5 number field
outputpublic (static)Outputs the value of the field directly, in a span
pageDropdownpublic (static)Generates a page dropdown selection menu
passwordpublic (static)Generates a password field
phonepublic (static)Renders a HTML5 phone number field (type=tel)
randomCodepublic (static)Render a 'generate code' button + text field
rangepublic (static)Generates a HTML5 range field
richtextpublic (static)Generates a richtext field - i.e. TinyMCE
setDatapublic (static)Sets the data that is used for form-building
setDropdownToppublic (static)Sets the text for the top item of dropdown lists.
setFieldValuepublic (static)Sets the value for a single field
simpledaterangepickerpublic (static)Renders simplified date range picker,
tagpublic (static)Generates an HTML opening tag, and possibly its closing tag, depending on the params specified
textpublic (static)Generates a text field
timepickerpublic (static)Renders a timepicker field inside a SPAN, which displays a dropdown date selection box when clicked
titlepublic (static)Generates the title for a field, possibly enclosing it in a label, possibly with a generated ID
totalselectorpublic (static)Renders HTML containing a total selector UI. Output field value for the total is in
uploadpublic (static)Generates a file upload field

protected addAttr

void Fb::addAttr ( array &$attrs , string $name , string $value );

Adds an HTML attribute to the list of attributes.
If the attribute has already been set, it will be left alone.
N.B. the 'class' attribute is always appended

public autoCompleteAddress

string Fb::autoCompleteAddress ( string $name , array $attrs , array $options );

Renders google autocomplete address fields

public autocomplete

string Fb::autocomplete ( string $name , array $attrs , array $options );

Returns HTML for an autocomplete selection menu.
Expects to be provided AJAX data in a format defined by jQuery UI (see 'url' option below).
By default, this expects to stores an ID value for a foreign key. If this isn't the desired
behaviour, a plain text value can be stored by setting the 'save_id' option to false.

The URL which handles the lookups needs to use the 'term' GET param to find matching values.
If 'save_id' is true, then it also needs to accept the 'id' GET param to fetch the label for the relevant id.
A call to the URL should return JSON which contains an array of hashes, each with the following keys:
- 'value': data for the text input.
- 'label': data for display in the drop-down list (if different from value).
           This is used as the value if 'value' isn't specified.
- 'id': id value to save. This should only be specified if 'save_id' is true; see below.

public autocompleteList

string Fb::autocompleteList ( string $name , array $attrs , array $options );

Render autocomplete multi-list

protected checkbox

unknown Fb::checkbox ( string $name , string $label , int|string $value , bool $selected , array $attrs );

Returns the HTML for a single checkbox

public checkboxBoolList

string Fb::checkboxBoolList ( string $name , array $attrs , array $settings );

Returns HTML containing multiple boolean checkboxes

public checkboxSet

string Fb::checkboxSet ( string $name , array $attrs , array $settings );

Returns HTML containing multiple checkboxes, with values to store in a SET column or similar

public chunkedUpload

unknown Fb::chunkedUpload ( string $name , array $attrs , array $params );

Generates a file upload field with a progress bar

To easily save the uploaded files in the form action function, see File::replaceSet

public colorpicker

string Fb::colorpicker ( string $name , array $attrs , array $params );

Renders a colour picker

Uses the HTML5 'color' input type, and loads a JS fallback (spectrum)
http://bgrins.github.io/spectrum/
Note that spectrum requires jQuery 1.6 or later

public conditionsList

string Fb::conditionsList ( string $name , array $attrs , array $params );

A conditions list, which is an interface for building rules for
use in dynamic IF-statement style systems.

Output POST data will be a JSON string of the condition rules,
as an array of objects with the keys 'field', 'op', 'val' for
each condition.

There are two parameters:
   fields   array    Available field types, name => label
   url      string   AJAX lookup method which returns the
                     operator and value lists

The lookup url is provided GET params 'field', 'op', 'val' and
should output JSON with two keys, 'op' and 'val', which are both
strings containing HTML for the fields; the op field should be
a SELECT and the val field should be an INPUT or a SELECT.

public datepicker

string Fb::datepicker ( string $name , array $attrs , array $options );

Renders HTML containing a date selection UI. Output field value is in YYYY-MM-DD

public daterangepicker

string Fb::daterangepicker ( string $name , array $attrs , array $options );

Renders a date range picker. Output is in the form of two fields (given in name as a comma separated list) e.g.
name => date_start, date_end will result in two fields: date_start => YYYY-MM-DD, date_end => YYYY-MM-DD

public datetimepicker

string Fb::datetimepicker ( string $name , array $attrs , array $options );

Renders HTML containing a date-time selection UI. Output field value is in YYYY-MM-DD HH:MM:SS

public datetimerangepicker

string Fb::datetimerangepicker ( string $name , array $attrs , array $options );

Renders a datetime range picker

Output is in the form of two fields (given in name as a comma separated list) e.g.
$name = 'date_start,date_end' will result in two fields:
date_start => YYYY-MM-DD HH:MM:SS, date_end => YYYY-MM-DD HH:MM:SS

public dropdown

string Fb::dropdown ( string $name , array $attrs , array $options );

Generates a dropdown selection menu

public dropdownItems

string Fb::dropdownItems ( array $options [, string|array $selected ] );

Returns HTML for a list of OPTIONs, and depending on the input array, OPTGROUP tags.

public dropdownTree

string Fb::dropdownTree ( string $name , array $attrs , array $options );

Generates a dropdown selection menu from a Treenode and its children

private dropdownTreeItem

string Fb::dropdownTreeItem ( Pagenode $node , int $depth , int $selected , array $exclude );

Used internally for recursive dropdown generation.

public email

string Fb::email ( string $name , array $attrs , array $options );

Renders a HTML5 email field

public fileSelector

string Fb::fileSelector ( string $name , array $attrs , array $options );

A file selection field, for use in the admin only.

private genId

string Fb::genId ( );

Generate a unique id

public geocodeAddress

string Fb::geocodeAddress ( string $name , array $attrs , array $options );

Renders place name geocoding fields

public getData

mixed Fb::getData ( string $name );

Gets the data for a single field from the data array

Properly handles PHP sub-arrays (e.g. 'options[food]'), doesn't handle
anon arrays though (e.g. 'options[]').

public googleMap

string Fb::googleMap ( string $name , array $attrs , array $params );

Render map location selector
Zoom field is optional

public heading

string Fb::heading ( string $heading );

Generates a heading using a H3 tag

public hiddenFields

string Fb::hiddenFields ( array $fields );

Renders a set of hidden fields

protected injectId

void Fb::injectId ( array &$attrs );

Injects the current auto-generated id into an array of attributes.
Only applies if an auto-generated id exists and an id isn't already set in the attributes.
The auto-generated id is then cleared.

public input

string Fb::input ( string $type , string $name , array $attrs );

Generates an HTML INPUT tag using Fb::tag, with auto-determined value

public lnk

string Fb::lnk ( string $name , array $attrs , array $options );

Render the UI for our multi-type link fields

public money

string Fb::money ( string $name , array $attrs , array $options );

Shows a HTML5 number field, formatted for dollar prices

public multiline

string Fb::multiline ( string $name , array $attrs );

Generates a multiline text field

public multipleFileSelect

string Fb::multipleFileSelect ( string $name , array $attrs , array $options );

UI for selecting or drag-and-drop uploading one or more files.

The field (refrenced by $name) is an array. If it's passed a a string, it will be comma-separated into an array.
As JsonForm will auto-convert arrays into comma-separated strings, this field can easily be used with a MySQL
field of type TEXT.

You cannot have more than one of these on the page at a time

This field WILL NOT operate in a non-admin environment

public multiradio

string Fb::multiradio ( string $name , array $attrs , array $options );

Returns HTML for a bunch of radiobuttons

public number

string Fb::number ( string $name , array $attrs );

Shows a HTML5 number field

public output

string Fb::output ( mixed $name , array $attrs );

Outputs the value of the field directly, in a span

public pageDropdown

string Fb::pageDropdown ( string $name , array $attrs , array $options );

Generates a page dropdown selection menu

Just a wrapper for Fb::dropdownTree

public password

string Fb::password ( string $name , array $attrs );

Generates a password field

public phone

string Fb::phone ( string $name , array $attrs , array $params );

Renders a HTML5 phone number field (type=tel)

public randomCode

void Fb::randomCode ( mixed $name , array $attrs , array $options );

Render a 'generate code' button + text field

public range

string Fb::range ( string $name , array $attrs , array $options );

Generates a HTML5 range field

public richtext

string Fb::richtext ( string $name , array $attrs , array $items );

Generates a richtext field - i.e. TinyMCE

public setData

void Fb::setData ( array $data );

Sets the data that is used for form-building
This is typically from a database row or saved session data
To set a single field, instead use Fb::setFieldValue

public setDropdownTop

void Fb::setDropdownTop ( string $label );

Sets the text for the top item of dropdown lists.
Set to an empty string to not show the top item.
This will be reset to the default value after every call to Fb::dropdown

public setFieldValue

void Fb::setFieldValue ( array $field , array $value );

Sets the value for a single field
This is the non-array version of Fb::setData

public simpledaterangepicker

string Fb::simpledaterangepicker ( string $name , array $attrs , array $options );

Renders simplified date range picker,
Output is in the form of two fields (given in name as a comma separated list) e.g.
name => date_start, date_end will result in two fields: date_start => YYYY-MM-DD, date_end => YYYY-MM-DD

public tag

string Fb::tag ( string $name , array $attrs , array $params );

Generates an HTML opening tag, and possibly its closing tag, depending on the params specified

You can specify either HTML or plain-text content, but not both

public text

string Fb::text ( string $name , array $attrs );

Generates a text field

public timepicker

string Fb::timepicker ( string $name , array $attrs , array $params );

Renders a timepicker field inside a SPAN, which displays a dropdown date selection box when clicked

public title

string Fb::title ( string $title [, string|null $id ] );

Generates the title for a field, possibly enclosing it in a label, possibly with a generated ID

public totalselector

string Fb::totalselector ( string $name , array $attrs , array $options );

Renders HTML containing a total selector UI. Output field value for the total is in
a hidden field. The specific counts for each are also available

public upload

string Fb::upload ( string $name , array $attrs );

Generates a file upload field