Quick and easy form builder
This is the code documentation for the SproutCMS project
Search documentation |
class FbQuick and easy form builder
Variables
Functions
protected addAttrvoid 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 autoCompleteAddressstring Fb::autoCompleteAddress ( string $name , array $attrs , array $options ); Renders google autocomplete address fields public autocompletestring 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 autocompleteListstring Fb::autocompleteList ( string $name , array $attrs , array $options ); Render autocomplete multi-list protected checkboxunknown Fb::checkbox ( string $name , string $label , int|string $value , bool $selected , array $attrs ); Returns the HTML for a single checkbox public checkboxBoolListstring Fb::checkboxBoolList ( string $name , array $attrs , array $settings ); Returns HTML containing multiple boolean checkboxes public checkboxSetstring Fb::checkboxSet ( string $name , array $attrs , array $settings ); Returns HTML containing multiple checkboxes, with values to store in a SET column or similar public chunkedUploadunknown 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 colorpickerstring 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 conditionsListstring 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 datepickerstring Fb::datepicker ( string $name , array $attrs , array $options ); Renders HTML containing a date selection UI. Output field value is in YYYY-MM-DD public daterangepickerstring 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 datetimepickerstring 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 datetimerangepickerstring 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 dropdownstring Fb::dropdown ( string $name , array $attrs , array $options ); Generates a dropdown selection menu public dropdownItemsstring Fb::dropdownItems ( array $options [, string|array $selected ] ); Returns HTML for a list of OPTIONs, and depending on the input array, OPTGROUP tags. public dropdownTreestring Fb::dropdownTree ( string $name , array $attrs , array $options ); Generates a dropdown selection menu from a Treenode and its children private dropdownTreeItemstring Fb::dropdownTreeItem ( Pagenode $node , int $depth , int $selected , array $exclude ); Used internally for recursive dropdown generation. public emailstring Fb::email ( string $name , array $attrs , array $options ); Renders a HTML5 email field public fileSelectorstring Fb::fileSelector ( string $name , array $attrs , array $options ); A file selection field, for use in the admin only. private genIdstring Fb::genId ( ); Generate a unique id public geocodeAddressstring Fb::geocodeAddress ( string $name , array $attrs , array $options ); Renders place name geocoding fields public getDatamixed 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 googleMapstring Fb::googleMap ( string $name , array $attrs , array $params ); Render map location selector Zoom field is optional public headingstring Fb::heading ( string $heading ); Generates a heading using a H3 tag public hiddenFieldsstring Fb::hiddenFields ( array $fields ); Renders a set of hidden fields protected injectIdvoid 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 inputstring Fb::input ( string $type , string $name , array $attrs ); Generates an HTML INPUT tag using Fb::tag, with auto-determined value public lnkstring Fb::lnk ( string $name , array $attrs , array $options ); Render the UI for our multi-type link fields public moneystring Fb::money ( string $name , array $attrs , array $options ); Shows a HTML5 number field, formatted for dollar prices public multilinestring Fb::multiline ( string $name , array $attrs ); Generates a multiline text field public multipleFileSelectstring 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 multiradiostring Fb::multiradio ( string $name , array $attrs , array $options ); Returns HTML for a bunch of radiobuttons public numberstring Fb::number ( string $name , array $attrs ); Shows a HTML5 number field public outputstring Fb::output ( mixed $name , array $attrs ); Outputs the value of the field directly, in a span public pageDropdownstring Fb::pageDropdown ( string $name , array $attrs , array $options ); Generates a page dropdown selection menu Just a wrapper for Fb::dropdownTree public passwordstring Fb::password ( string $name , array $attrs ); Generates a password field public phonestring Fb::phone ( string $name , array $attrs , array $params ); Renders a HTML5 phone number field (type=tel) public randomCodevoid Fb::randomCode ( mixed $name , array $attrs , array $options ); Render a 'generate code' button + text field public rangestring Fb::range ( string $name , array $attrs , array $options ); Generates a HTML5 range field public richtextstring Fb::richtext ( string $name , array $attrs , array $items ); Generates a richtext field - i.e. TinyMCE public setDatavoid 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 setDropdownTopvoid 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 setFieldValuevoid Fb::setFieldValue ( array $field , array $value ); Sets the value for a single field This is the non-array version of Fb::setData public simpledaterangepickerstring 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 tagstring 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 textstring Fb::text ( string $name , array $attrs ); Generates a text field public timepickerstring 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 titlestring 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 totalselectorstring 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 uploadstring Fb::upload ( string $name , array $attrs ); Generates a file upload field |
| Powered by Pelzini, version 0.9.0 |
Documentation is made available under the
GNU Free Documentation License 1.2. Generated: Tuesday, 15th September, 2026 at 10:26 am |
|