SproutCMS

This is the code documentation for the SproutCMS project

Page options:

Inherited members

class JsonForm

Processes forms using configuration stored in a JSON file which specifies database columns, their HTML input fields,
and validation rules.
A generic implementation which should work for most cases is found in ManagedAdminController::_getEditForm
(generates the form) and Controller::saveJsonData (saves the POST submission)

Functions

NameVisibilityDescription
argReplaceprivate (static)Replace magic strings in "args" arrays with various metadata values
autofillOptionDefaultspublic (static)Determine the auto-generated default values for an autofill-list
changeFieldRequiredprotected (static)Modify a JSON form config to change the 'required' status of a particular field
collateDatapublic (static)Collates POST data using specified config options
collateFieldDataprotected (static)Collates a single field's $_POST data for INSERT/UPDATE queries, and performs validation
expandItemDefnspublic (static)Expands item definitions for a field pulled from JSON
flattenGroupspublic (static)Extract field defns from a list (which may include groups)
loadAutofillListDatapublic (static)Loads autofill_list data for use on a view
loadMultiEditDatapublic (static)Loads multiedit data for use on a view
makeOptionalpublic (static)Modify a JSON form config to make a particular field optional
makeRequiredpublic (static)Modify a JSON form config to make a particular field required
renderFieldpublic (static)Renders the input for a field definition pulled from a JSON file
renderTabItempublic (static)Render a tab item, which may be a field, heading, html block, etc
setParameterForColumnspublic (static)Set a parameter for fields to be a specific value, for one or more columns

private argReplace

array JsonForm::argReplace ( array $args , array $metadata );

Replace magic strings in "args" arrays with various metadata values

Replacements:
    %%       The current record id

public autofillOptionDefaults

array JsonForm::autofillOptionDefaults ( array $auto , string $local_table_name );

Determine the auto-generated default values for an autofill-list

Defaults:
    joiner_local_col        Singular of local table name + '_id'
    joiner_foreign_col      Singular of the foreign_table option + '_id'
    foreign_label_col       'name'
    reorder                 false

protected changeFieldRequired

void JsonForm::changeFieldRequired ( array &$conf , string $field_name , bool $required );

Modify a JSON form config to change the 'required' status of a particular field
This implements JsonForm::makeOptional and JsonForm::makeRequired

public collateData

array JsonForm::collateData ( array $conf , string $mode , Validator $validator , int $item_id );

Collates POST data using specified config options

protected collateFieldData

void JsonForm::collateFieldData ( array $field_defn , string $input , array $metadata , Validator $valid , array &$data );

Collates a single field's $_POST data for INSERT/UPDATE queries, and performs validation

public expandItemDefns

void JsonForm::expandItemDefns ( array &$field , array $metadata );

Expands item definitions for a field pulled from JSON

public flattenGroups

array JsonForm::flattenGroups ( array $items );

Extract field defns from a list (which may include groups)

public loadAutofillListData

array JsonForm::loadAutofillListData ( array $conf , string $local_table_name , int $local_record_id , array $conditions );

Loads autofill_list data for use on a view

public loadMultiEditData

array JsonForm::loadMultiEditData ( array $conf , string $default_link , int $record_id , array $conditions );

Loads multiedit data for use on a view

public makeOptional

void JsonForm::makeOptional ( array &$conf , string $field_name );

Modify a JSON form config to make a particular field optional

public makeRequired

void JsonForm::makeRequired ( array &$conf , string $field_name );

Modify a JSON form config to make a particular field required

public renderField

string JsonForm::renderField ( array $field [, string $name_prepend , array $metadata ] );

Renders the input for a field definition pulled from a JSON file

public renderTabItem

html JsonForm::renderTabItem ( array $item , string $for , int $id , array $data , array $errors [, string $name_prepend ] );

Render a tab item, which may be a field, heading, html block, etc

public setParameterForColumns

null JsonForm::setParameterForColumns ( array &$items , array $columns , string $key , string $val );

Set a parameter for fields to be a specific value, for one or more columns