SproutCMS

This is the code documentation for the SproutCMS project

Page options:

Inherited members

class LightweightForm

A variation of the Form helper which doesn't output errors, labels or helptext
Wraps form fields (e.g. from Fb) with additional HTML.

Variables

NameVisibilityDescription
$errors (static) 
$id_prefix (static) 
$name_format (static) 
$next_helptext (static) 
$next_label (static) 
$next_required (static) 

Functions

NameVisibilityDescription
__callStaticpublic (static)Auto-wrapper around Fb methods
autofillListpublic (static)Returns HTML for an auto-complete list of records
checkboxListpublic (static)Returns HTML for a list of checkboxes, applying name conversions along the way
convertFieldNameprotected (static)Format a field name as per the specification defined by Form::setFieldNameFormat
fieldAutopublic (static)Return HTML for a field, with the wrapping HTML detected automatically.
fieldFieldsetpublic (static)Return HTML for a field wrapped in a FIELDSET
fieldMethodClassprotected (static)Convert a full method name (e.g. Sprout\Helpers\Fb::text) into a friendly class name
fieldPlainpublic (static)Return HTML for a 'plain' field, i.e. one which doesn't require a FIELDSET wrapped around it.
genIdprotected (static)Generate a unique id which should be stable across calls to this URL
getDatapublic (static)Gets the form per-field value for a single field
getFieldErrorspublic (static)Return the errors for a given field
htmlpublic (static)Return HTML which has been wrapped in the form field DIVs
loadFromSessionpublic (static)Load data and errors from the session, with optional record id validation
moneypublic (static)Returns HTML for a money field, using Fb::money to generate the field itself
multiradiopublic (static)Returns HTML for a bunch of radiobuttons, using Fb::multiradio to generate the fields
nextFieldDetailspublic (static)Set the details for the next field which will be outputted.
numberpublic (static)Returns HTML for a number field, using Fb::number to generate the field itself
outpublic (static)Return content which has been HTML-encoded and wrapped in the form field DIVs
passStringprotected (static)Returns the first argument
passwordpublic (static)Returns HTML for a password field, using Fb::password to generate the field itself
resetFieldpublic (static)Reset the state machine for field values
setDatapublic (static)Set form per-field values for the fields
setErrorspublic (static)Set per-field error messages to display
setFieldIdPrefixpublic (static)Sets the prefix for generated IDs
setFieldNameFormatpublic (static)Set a format string which will alter the field name prior to being passed to the underlying render method
setFieldValuepublic (static)Sets the value for a single field
textpublic (static)Returns HTML for a text field, using Fb::text to generate the field itself

public __callStatic (from Form)

string Form::__callStatic ( string $func , array $args );

Auto-wrapper around Fb methods

Will wrap the Fb method with the same name as the called method, e.g. Form::datepicker wraps Fb::datepicker
Wrapping is done using Form::fieldAuto

public autofillList (from Form)

string Form::autofillList ( string $name , array $attrs , array $options );

Returns HTML for an auto-complete list of records

The form data for this field should be an array of arrays with at least the following keys:
[
    'id' => record ID,
    'value' => title text visible in the list item,
    'orderkey' => ordinal value for record ordering
]

public checkboxList (from Form)

string Form::checkboxList ( array $checkboxes , array $attrs );

Returns HTML for a list of checkboxes, applying name conversions along the way

Uses Fb::checkboxBoolList to generate the underlying checkbox list

protected convertFieldName (from Form)

string Form::convertFieldName ( string $name );

Format a field name as per the specification defined by Form::setFieldNameFormat

public fieldAuto (from Form)

string Form::fieldAuto ( callable $method , string $name , array $attrs , array $options );

Return HTML for a field, with the wrapping HTML detected automatically.

To enable fieldset wrapping, add the docblock tag @wrap-in-fieldset to the field generation method

public fieldFieldset

string LightweightForm::fieldFieldset ( callable $method , string $name , array $attrs , array $options );

Return HTML for a field wrapped in a FIELDSET

The main wrapping DIV will contain additional classes if the field is required, disabled or has an error.
A class is also output for hte field method name (if the name contains "Sprout\Helpers\Fb::" this is removed)
If the field has an explicit ID set, that will be added as a class on the wrapper too.

protected fieldMethodClass (from Form)

string Form::fieldMethodClass ( string $method );

Convert a full method name (e.g. Sprout\Helpers\Fb::text) into a friendly class name

The classes Fb and Form aren't emitted, but all other class names are

public fieldPlain

string LightweightForm::fieldPlain ( callable $method , string $name , array $attrs , array $options );

Return HTML for a 'plain' field, i.e. one which doesn't require a FIELDSET wrapped around it.

The main wrapping DIV will contain additional classes if the field is required, disabled or has an error.
A class is also output for hte field method name (if the name contains "Sprout\Helpers\Fb::" this is removed)
If the field has an explicit ID set, that will be added as a class on the wrapper too.

protected genId (from Form)

string Form::genId ( );

Generate a unique id which should be stable across calls to this URL
as long as the number and order of fields on the page remains the same

public getData (from Form)

unknown Form::getData ( string $field );

Gets the form per-field value for a single field

As form field datas are stored using the Fb class, this method just gets the data from there

public getFieldErrors (from Form)

NULL|array Form::getFieldErrors ( string $field_name );

Return the errors for a given field

Supports nested error arrays; If $field_name is something like member[5][test] then the error
will be read from self::$errors['member']['5']['test']

public html (from Form)

string Form::html ( string $html );

Return HTML which has been wrapped in the form field DIVs

public loadFromSession (from Form)

null|array Form::loadFromSession ( string $key [, mixed $verify_record_id ] );

Load data and errors from the session, with optional record id validation

Expected session keys:
    record_id       Checked against $verify_record_id, session data is thrown away in case of mismatch
    field_values    Field data, loaded using Form::setData
    field_errors    Field errors, loaded using Form::setErrors

public money (from Form)

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

Returns HTML for a money field, using Fb::money to generate the field itself

public multiradio (from Form)

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

Returns HTML for a bunch of radiobuttons, using Fb::multiradio to generate the fields

public nextFieldDetails (from Form)

void Form::nextFieldDetails ( string $label , bool $required [, string $helptext ] );

Set the details for the next field which will be outputted.

After returning a field, these values will be cleared from the state machine

Both the label and helptext support a subset of HTML, Text::limitedSubsetHtml for more details

public number (from Form)

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

Returns HTML for a number field, using Fb::number to generate the field itself

public out (from Form)

string Form::out ( string $plain );

Return content which has been HTML-encoded and wrapped in the form field DIVs

protected passString (from Form)

string Form::passString ( string $str );

Returns the first argument

This hacky little method works around the fact that fieldPlain only accepts a method name

public password (from Form)

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

Returns HTML for a password field, using Fb::password to generate the field itself

public resetField (from Form)

void Form::resetField ( );

Reset the state machine for field values

public setData (from Form)

void Form::setData ( array $data );

Set form per-field values for the fields

As form fields are rendered using the Fb class, this method just sets the data there

public setErrors (from Form)

void Form::setErrors ( array $errors );

Set per-field error messages to display

A given field can have either a single error message or an array of errors
The output from the Validator::getFieldErrors method can be used directly as input to this method

public setFieldIdPrefix (from Form)

void Form::setFieldIdPrefix ( string $prefix );

Sets the prefix for generated IDs

public setFieldNameFormat (from Form)

void Form::setFieldNameFormat ( string $format );

Set a format string which will alter the field name prior to being passed to the underlying render method

Formatting is done using sprintf
A single parameter is provided to the sprintf() call, the field name
The default format does no transformation, i.e. the string '%s'
This parameter persists across multiple form fields

public setFieldValue (from Form)

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

Sets the value for a single field

As form fields are rendered using the Fb class, this method just sets the data there

public text (from Form)

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

Returns HTML for a text field, using Fb::text to generate the field itself