This is the API docs for LemonStand V1, which has been discontinued. LemonStand is now a cloud based platform, available at lemonstand.com.

LemonStand API

Db_FormFieldDefinition class

Defined in /phproad/modules/db/classes/db_formfielddefinition.php, lines 40-1278
Inheritance Db_FormElement » Db_FormFieldDefinition
Author LemonStand eCommerce Inc.
Represents a model form field definition. Objects of this class are used for defining form field properties in models. List Behavior use data from form definition objects to display fields in forms.
Almost every class property has a method with a matching name and usually properties are not used directly. Class methods can be called as a chain:
$this->add_form_field('price_tiers')->tab('Pricing')->renderAs('price_tiers');

Public properties

Show inherited properties.

Property Type Description Defined By
addAttachmentLabel string specifies prompt message for a file attachment field. Db_FormFieldDefinition
checkboxOnState string specifies value corresponding the on state of a checkbox field. Db_FormFieldDefinition
collapsable boolean determines whether the element should be placed to the collapsable form area. Db_FormElement
comment string specifies the element comment. Db_FormFieldDefinition
commentHTML boolean determines whether the comment contains HTML tags. Db_FormFieldDefinition
commentPosition string specifies the comment position. Db_FormFieldDefinition
commentTooltip string specifies a tooltip text for the field comment. Db_FormFieldDefinition
cssClasses string specifies CSS class to be applied to the field container element. Db_FormFieldDefinition
cssClassName string specifies CSS class to be applied to the field LI element. Db_FormFieldDefinition
dbName string specifies the database column or relation name. Db_FormFieldDefinition
disabled boolean determines whether the field is disabled on the form. Db_FormFieldDefinition
emptyOption string specifies a label corresponding an empty option for drop-down elements. Db_FormFieldDefinition
fileDownloadBaseUrl string sets a base URL for file links for a file attachments field. Db_FormFieldDefinition
formElementPartial string specifies name of a partial to render instead of the normal form field markup. Db_FormFieldDefinition
formSide string specifies the form side the element should be placed to. Db_FormFieldDefinition
gridColumns array defines column configuration for a grid field. Db_FormFieldDefinition
gridSettings array defines configuration of a grid field. Db_FormFieldDefinition
hideContent boolean determines a text area content should be hidden in a form. Db_FormFieldDefinition
htmlAllowMoreColors boolean specifies whether TinyMCE "more colors" feature is available for a HTML field. Db_FormFieldDefinition
htmlBackgroundColors string specifies a list of TinyMCE background colors for a HTML field. Db_FormFieldDefinition
htmlBlockFormats string specifies a list of TinyMCE block formats for a HTML field. Db_FormFieldDefinition
htmlButtons1 string specifies a list of TinyMCE toolbar #1 buttons for a HTML field. Db_FormFieldDefinition
htmlButtons2 string specifies a list of TinyMCE toolbar #2 buttons for a HTML field. Db_FormFieldDefinition
htmlButtons3 string specifies a list of TinyMCE toolbar #3 buttons for a HTML field. Db_FormFieldDefinition
htmlContentCss string specifies URL of a CSS file to style content of a TinyMCE editor for a HTML field. Db_FormFieldDefinition
htmlCustomStyles string specifies a list of TinyMCE custom styles for a HTML field. Db_FormFieldDefinition
htmlFontColors string specifies a list of TinyMCE font colors for a HTML field. Db_FormFieldDefinition
htmlFontSizes string specifies a list of TinyMCE font sizes for a HTML field. Db_FormFieldDefinition
htmlFullWidth boolean determines whether the HTML field should be full-width. Db_FormFieldDefinition
htmlPlugins string specifies a list of TinyMCE plugins for a HTML field. Db_FormFieldDefinition
htmlValidChildElements string specifies a list of TinyMCE valid child elements for a HTML field. Db_FormFieldDefinition
htmlValidElements string specifies a list of TinyMCE valid elements for a HTML field. Db_FormFieldDefinition
imageThumbSize integer specifies thumbnail size (both width and height) for an image field. Db_FormFieldDefinition
language string specifies language for a code editor field. Db_FormFieldDefinition
nl2br string specifies whether new lines in the field value should be converted to line breaks in a form preview. Db_FormFieldDefinition
noAttachmentsLabel string specifies a message to display in a file attachment field if there are no files attached. Db_FormFieldDefinition
noForm boolean hides the element from forms. Db_FormElement
noLabel boolean determines whether the element form label is invisible. Db_FormFieldDefinition
noOptions string specifies a text to display in multi-relation fields in case if no options were selected. Db_FormFieldDefinition
noPreview boolean makes the element invisible in the form preview. Db_FormElement
optionsHtmlEncode boolean determines where options in a drop-down field should be HTML-encoded before they are displayed. Db_FormFieldDefinition
optionsMethod string specifies the common model's method name responsible for returning a list of options for a multi-option field. Db_FormFieldDefinition
optionStateMethod string specifies the common model's method name responsible for returning option state for a multi-option field. Db_FormFieldDefinition
previewComment string specifies the element comment for the form preview. Db_FormFieldDefinition
previewHelp string specifies HTML help string to be displayed in a form preview. Db_FormFieldDefinition
previewLink string specifies an URL for the field preview link. Db_FormFieldDefinition
previewNoRelation boolean determines whether the relation preview is available for a relation field on the preview form. Db_FormFieldDefinition
referenceDescriptionField string specifies a SQL expression for fetching option descriptions in reference-type fields. Db_FormFieldDefinition
referenceFilter string specifies a SQL expression for filtering reference-type fields. Db_FormFieldDefinition
referenceSort string specifies a SQL expression for ordering options in reference-type fields. Db_FormFieldDefinition
relationPreviewNoOptions string specifies a text to be displayed for a relation field on the preview form when the field has no related records. Db_FormFieldDefinition
renderFilesAs string specifies a render mode for a file attachment field. Db_FormFieldDefinition
renderMode string specifies the field render mode. Db_FormFieldDefinition
renderOptions array specifies rendering options for complex fields and widgets. Db_FormFieldDefinition
saveCallback string specifies JavaScript function name to be executed when Save button is clicked in a HTML field. Db_FormFieldDefinition
size string specifies a size of textarea fields. Db_FormFieldDefinition
sortOrder integer specifies the element position in a form. Db_FormElement
tab string specifies the form tab name. Db_FormElement
titlePartial string specifies name of a partial to render below the form field caption. Db_FormFieldDefinition

Public methods

Show inherited methods.

Method Description Defined By
addDocumentLabel() sets prompt message for a file attachment field. Db_FormFieldDefinition
checkboxOnState() sets value corresponding the on state of a checkbox field. Db_FormFieldDefinition
collapsable() places the element to the form or tab collapsable area. Db_FormElement
comment() sets the element comment. Db_FormFieldDefinition
commentTooltip() specifies a tooltip text for the field comment. Db_FormFieldDefinition
cssClasses() sets CSS class to be applied to the field container element. Db_FormFieldDefinition
cssClassName() sets a CSS class name to apply to the field LI element. Db_FormFieldDefinition
disabled() disables the form field. Db_FormFieldDefinition
emptyOption() specifies a label corresponding an empty option for drop-down elements. Db_FormFieldDefinition
fileDownloadBaseUrl() sets a base URL for file links for a file attachments field. Db_FormFieldDefinition
formElementPartial() allows to render a specific partial instead of the standard field type specific partial. Db_FormFieldDefinition
getColDefinition() returns the model column definition corresponding the form field. Db_FormFieldDefinition
gridColumns() defines column configuration for a grid field. Db_FormFieldDefinition
gridSettings() defines configuration of a grid field. Db_FormFieldDefinition
hideContent() hides a text area content in a form. Db_FormFieldDefinition
htmlAllowMoreColors() this option enables you to disable the "more colors" link in a HTML field for text and background color menus. Db_FormFieldDefinition
htmlBackgroundColors() sets a list of TinyMCE background colors for a HTML field. Db_FormFieldDefinition
htmlBlockFormats() sets a list of TinyMCE block formats for a HTML field. Db_FormFieldDefinition
htmlButtons1() sets a list of buttons to be displayed in the 1st row of HTML field toolbar. Db_FormFieldDefinition
htmlButtons2() sets a list of buttons to be displayed in the 2nd row of HTML field toolbar. Db_FormFieldDefinition
htmlButtons3() sets a list of buttons to be displayed in the 3rd row of HTML field toolbar. Db_FormFieldDefinition
htmlContentCss() sets a custom CSS file to be used to style HTML field content. Db_FormFieldDefinition
htmlCustomStyles() sets a list of TinyMCE custom styles for a HTML field. Db_FormFieldDefinition
htmlFontColors() specifies a list of TinyMCE font colors for a HTML field. Db_FormFieldDefinition
htmlFontSizes() sets a list of TinyMCE font sizes for a HTML field. Db_FormFieldDefinition
htmlFullWidht() determines whether the HTML field should be full-width. Db_FormFieldDefinition
htmlFullWidth() determines whether the HTML field should be full-width. Db_FormFieldDefinition
htmlPlugins() adds a list of TinyMCE plugins for a HTML field. Db_FormFieldDefinition
htmlValidChildElements() sets a list of TinyMCE valid child elements for a HTML field. Db_FormFieldDefinition
htmlValidElements() sets a list of TinyMCE valid elements for a HTML field. Db_FormFieldDefinition
imageThumbSize() sets thumbnail size (both width and height) for an image field. Db_FormFieldDefinition
language() sets a language for code editor fields syntax highlighting. Db_FormFieldDefinition
nl2br() determines whether new lines in the field value should be converted to line breaks in a form preview. Db_FormFieldDefinition
noAttachmentsLabel() sets a message to display in a file attachment field if there are no files attached. Db_FormFieldDefinition
noForm() hides the element from the form. Db_FormElement
noLabel() hides the element form label. Db_FormFieldDefinition
noOptions() sets a text to display in multi-relation fields in case if no options were selected. Db_FormFieldDefinition
noPreview() hides the element from the form preview. Db_FormElement
optionsHtmlEncode() determines where options in a drop-down field should be HTML-encoded before they are displayed. Db_FormFieldDefinition
optionsMethod() sets the common model's method name responsible for returning a list of options for a multi-option field. Db_FormFieldDefinition
optionStateMethod() sets the common model's method name responsible for returning option state for a multi-option field. Db_FormFieldDefinition
placeholder() sets the placeholder for the form field. Use the second parameter when setting the placeholder for multi-field form fields like datetime. Db_FormFieldDefinition
previewComment() sets the element comment for the form preview. Db_FormFieldDefinition
previewHelp() specifies HTML help string to be displayed in a form preview. Db_FormFieldDefinition
previewLink() sets an URL for the field preview link. Db_FormFieldDefinition
previewNoOptionsMessage() sets a text to be displayed for a relation field on the preview form when the field has no related records. Db_FormFieldDefinition
previewNoRelation() determines whether the relation preview is hidden for a relation field on the preview form. Db_FormFieldDefinition
referenceDescriptionField() sets a SQL expression for fetching option descriptions in reference-type fields. Db_FormFieldDefinition
referenceFilter() sets SQL expression for filtering reference-type fields. Db_FormFieldDefinition
referenceSort() sets a SQL expression for ordering options in reference-type fields. Db_FormFieldDefinition
renderAs() specifies the field render mode. Db_FormFieldDefinition
renderFilesAs() sets a render mode for a file attachment field. Db_FormFieldDefinition
saveCallback() sets a JavaScript function name to be executed when a user clicks Save button on the HTML editor toolbar. Db_FormFieldDefinition
side() sets the form side the field should be placed to. Db_FormFieldDefinition
size() sets a size of textarea fields. Db_FormFieldDefinition
sortOrder() sets the element position on the form. Db_FormElement
tab() specifies a caption of the tab to place the field to. Db_FormElement
titlePartial() specifies name of a partial to render below the form field caption. Db_FormFieldDefinition
validation() returns the validation rule set object corresponding to the form field. Db_FormFieldDefinition

Property details

addAttachmentLabel property

public string $addAttachmentLabel;
Specifies prompt message for a file attachment field.

checkboxOnState property

public string $checkboxOnState;
Specifies value corresponding the on state of a checkbox field.

comment property

public string $comment;
Specifies the element comment. Comments are displayed on the form below or above the element. See comment() method for details.

commentHTML property

public boolean $commentHTML;
Determines whether the comment contains HTML tags. See comment() method for details.

commentPosition property

public string $commentPosition;
Specifies the comment position. Supported values are above or below. See comment() method for details.

commentTooltip property

public string $commentTooltip;
Specifies a tooltip text for the field comment.

cssClasses property

public string $cssClasses;
Specifies CSS class to be applied to the field container element.

cssClassName property

public string $cssClassName;
Specifies CSS class to be applied to the field LI element.

dbName property

public string $dbName;
Specifies the database column or relation name.

disabled property

public boolean $disabled;
Determines whether the field is disabled on the form.

emptyOption property

public string $emptyOption;
Specifies a label corresponding an empty option for drop-down elements. See emptyOption() method for details.

fileDownloadBaseUrl property

public string $fileDownloadBaseUrl;
Sets a base URL for file links for a file attachments field.

formElementPartial property

public string $formElementPartial;
Specifies name of a partial to render instead of the normal form field markup.

formSide property

public string $formSide;
Specifies the form side the element should be placed to. Supported values are left, right, full.

gridColumns property

public array $gridColumns;
Defines column configuration for a grid field. See gridColumns() method for details.

gridSettings property

public array $gridSettings;
Defines configuration of a grid field. See gridSettings() method for details.

hideContent property

public boolean $hideContent;
Determines a text area content should be hidden in a form.

htmlAllowMoreColors property

public boolean $htmlAllowMoreColors;
Specifies whether TinyMCE "more colors" feature is available for a HTML field.

htmlBackgroundColors property

public string $htmlBackgroundColors;
Specifies a list of TinyMCE background colors for a HTML field.

htmlBlockFormats property

public string $htmlBlockFormats;
Specifies a list of TinyMCE block formats for a HTML field.

htmlButtons1 property

public string $htmlButtons1;
Specifies a list of TinyMCE toolbar #1 buttons for a HTML field.

htmlButtons2 property

public string $htmlButtons2;
Specifies a list of TinyMCE toolbar #2 buttons for a HTML field.

htmlButtons3 property

public string $htmlButtons3;
Specifies a list of TinyMCE toolbar #3 buttons for a HTML field.

htmlContentCss property

public string $htmlContentCss;
Specifies URL of a CSS file to style content of a TinyMCE editor for a HTML field. The URL should be relative to LemonStand application root.

htmlCustomStyles property

public string $htmlCustomStyles;
Specifies a list of TinyMCE custom styles for a HTML field.

htmlFontColors property

public string $htmlFontColors;
Specifies a list of TinyMCE font colors for a HTML field.

htmlFontSizes property

public string $htmlFontSizes;
Specifies a list of TinyMCE font sizes for a HTML field.

htmlFullWidth property

public boolean $htmlFullWidth;
Determines whether the HTML field should be full-width.

htmlPlugins property

public string $htmlPlugins;
Specifies a list of TinyMCE plugins for a HTML field.

htmlValidChildElements property

public string $htmlValidChildElements;
Specifies a list of TinyMCE valid child elements for a HTML field.

htmlValidElements property

public string $htmlValidElements;
Specifies a list of TinyMCE valid elements for a HTML field.

imageThumbSize property

public integer $imageThumbSize;
Specifies thumbnail size (both width and height) for an image field.

language property

public string $language;
Specifies language for a code editor field. See language() method for details.

nl2br property

public string $nl2br;
Specifies whether new lines in the field value should be converted to line breaks in a form preview.

noAttachmentsLabel property

public string $noAttachmentsLabel;
Specifies a message to display in a file attachment field if there are no files attached.

noLabel property

public boolean $noLabel;
Determines whether the element form label is invisible.

noOptions property

public string $noOptions;
Specifies a text to display in multi-relation fields in case if no options were selected.

optionsHtmlEncode property

public boolean $optionsHtmlEncode;
Determines where options in a drop-down field should be HTML-encoded before they are displayed.

optionsMethod property

public string $optionsMethod;
Specifies the common model's method name responsible for returning a list of options for a multi-option field. See optionsMethod() method for details.

optionStateMethod property

public string $optionStateMethod;
Specifies the common model's method name responsible for returning option state for a multi-option field. See optionStateMethod() method for details.

previewComment property

public string $previewComment;
Specifies the element comment for the form preview. By default the preview comment matches the regular form comment. See previewComment() method for details.

previewHelp property

public string $previewHelp;
Specifies HTML help string to be displayed in a form preview.

previewLink property

public string $previewLink;
Specifies an URL for the field preview link.

previewNoRelation property

public boolean $previewNoRelation;
Determines whether the relation preview is available for a relation field on the preview form.

referenceDescriptionField property

public string $referenceDescriptionField;
Specifies a SQL expression for fetching option descriptions in reference-type fields. See referenceDescriptionField() method for details.

referenceFilter property

public string $referenceFilter;
Specifies a SQL expression for filtering reference-type fields. See referenceFilter() method for details.

referenceSort property

public string $referenceSort;
Specifies a SQL expression for ordering options in reference-type fields. See referenceSort() method for details.

relationPreviewNoOptions property

public string $relationPreviewNoOptions;
Specifies a text to be displayed for a relation field on the preview form when the field has no related records.

renderFilesAs property

public string $renderFilesAs;
Specifies a render mode for a file attachment field. See renderFilesAs() method for details.

renderMode property

public string $renderMode;
Specifies the field render mode. See renderAs() method for details about supported render modes.

renderOptions property

public array $renderOptions;
Specifies rendering options for complex fields and widgets. See documentation for a specific field for details.

saveCallback property

public string $saveCallback;
Specifies JavaScript function name to be executed when Save button is clicked in a HTML field.

size property

public string $size;
Specifies a size of textarea fields. See size() method for details.

titlePartial property

public string $titlePartial;
Specifies name of a partial to render below the form field caption.

Method details

addDocumentLabel() method

public Db_FormFieldDefinition addDocumentLabel(string $label)
$label string specifies the label text.
{return} Db_FormFieldDefinition returns the updated form field definition object.
Sets prompt message for a file attachment field.

checkboxOnState() method

public Db_FormFieldDefinition checkboxOnState(string $value)
$value string specifies the value.
{return} Db_FormFieldDefinition returns the updated form field definition object.
Sets value corresponding the on state of a checkbox field.

comment() method

public Db_FormFieldDefinition comment(string $text, string $position='below', bool $commentHTML=false)
$text string specifies the comment text.
$position string specifies a comment position. Supported values are: above, below.
$commentHTML bool determines whether the comment contains HTML tags which should be preserved.
{return} Db_FormFieldDefinition returns the updated form field definition object.
Sets the element comment. Comments are displayed on the form below or above the element.

commentTooltip() method

public Db_FormFieldDefinition commentTooltip(string $help_string)
$help_string string specifies the tooltip string.
{return} Db_FormFieldDefinition returns the updated form field definition object.
Specifies a tooltip text for the field comment.

cssClasses() method

public Db_FormFieldDefinition cssClasses(string $classes)
$classes string specifies a string containing CSS class name(s);
{return} Db_FormFieldDefinition returns the updated form field definition object.
Sets CSS class to be applied to the field container element.

cssClassName() method

public Db_FormFieldDefinition cssClassName(string $classes)
$classes string specifies a string containing CSS class name(s);
{return} Db_FormFieldDefinition returns the updated form field definition object.
Sets a CSS class name to apply to the field LI element.

disabled() method

public Db_FormFieldDefinition disabled()
{return} Db_FormFieldDefinition returns the updated form field definition object.
Disables the form field.

emptyOption() method

public Db_FormFieldDefinition emptyOption(string $text)
$text string specifies the option text.
{return} Db_FormFieldDefinition returns the updated form field definition object.
Specifies a label corresponding an empty option for drop-down elements Use this method for the default empty option like <please select color>.

fileDownloadBaseUrl() method

public Db_FormFieldDefinition fileDownloadBaseUrl(string $url)
$url string specifies the base URL.
{return} Db_FormFieldDefinition returns the updated form field definition object.
Sets a base URL for file links for a file attachments field. Usual value for this method is url('ls_backend/files/get/').

See Also

formElementPartial() method

public Db_FormFieldDefinition formElementPartial(string $partial_name)
$partial_name string specifies the partial name or an absolute partial's file path.
{return} Db_FormFieldDefinition returns the updated form field definition object.
Allows to render a specific partial instead of the standard field type specific partial The partial file should be placed to the views directory of the controller which renders the form. Alternatively you can specify the absolute pat to the partial.

getColDefinition() method

public Db_ColumnDefinition getColDefinition()
{return} Db_ColumnDefinition returns the column definition object.
Returns the model column definition corresponding the form field.

gridColumns() method

public Db_FormFieldDefinition gridColumns(array $columns)
$columns array the column configuration array.
{return} Db_FormFieldDefinition returns the updated form field definition object.
Defines column configuration for a grid field. Grid control requires the corresponding model column to contain an array with the grid data. Usually the data is contained in a text filed and serialized before the model data is saved to the database. Column configuration is defined as an associative array with column identifiers in the array keys and column settings in the values. Example of the configuration array:
array(
 'country'=>array('title'=>'Country Code', 'align'=>'left'), 
 'state'=>array('title'=>'State Code', 'align'=>'left', 'width'=>'100'), 
 'read_only_col'=>array('title'=>'Read only', 'read_only'=>true)
)

See Also

gridSettings() method

public Db_FormFieldDefinition gridSettings(array $settings)
$settings array specifies the grid settings.
{return} Db_FormFieldDefinition returns the updated form field definition object.
Defines configuration of a grid field. The grid control configuration is defined as an array. Example configuration:
array(
  'no_toolbar'=>true, 
  'allow_adding_rows'=>false, 
  'allow_deleting_rows'=>false, 
  'no_sorting'=>false
)

See Also

hideContent() method

public Db_FormFieldDefinition hideContent()
{return} Db_FormFieldDefinition returns the updated form field definition object.
Hides a text area content in a form.

htmlAllowMoreColors() method

public Db_FormFieldDefinition htmlAllowMoreColors(string $allow)
$allow string indicates whether the more colors link should be enabled.
{return} Db_FormFieldDefinition returns the updated form field definition object.
This option enables you to disable the "more colors" link in a HTML field for text and background color menus.

htmlBackgroundColors() method

public Db_FormFieldDefinition htmlBackgroundColors(string $colors)
$colors string specifies a comma-separated list of colors: "FF00FF,FFFF00,000000".
{return} Db_FormFieldDefinition returns the updated form field definition object.
Sets a list of TinyMCE background colors for a HTML field. Please refer TinyMCE documentation for details about background colors.

htmlBlockFormats() method

public Db_FormFieldDefinition htmlBlockFormats(string $formats)
$formats string specifies a comma-separated list of formats
{return} Db_FormFieldDefinition returns the updated form field definition object.
Sets a list of TinyMCE block formats for a HTML field. Please refer TinyMCE documentation for details about block formats.

htmlButtons1() method

public Db_FormFieldDefinition htmlButtons1(string $buttons)
$buttons string a list of buttons to display.
{return} Db_FormFieldDefinition returns the updated form field definition object.
Sets a list of buttons to be displayed in the 1st row of HTML field toolbar. Please refer to TinyMCE documentation for details about buttons.

htmlButtons2() method

public Db_FormFieldDefinition htmlButtons2(string $buttons)
$buttons string a list of buttons to display.
{return} Db_FormFieldDefinition returns the updated form field definition object.
Sets a list of buttons to be displayed in the 2nd row of HTML field toolbar. Please refer TinyMCE documentation for details about buttons.

htmlButtons3() method

public Db_FormFieldDefinition htmlButtons3(string $buttons)
$buttons string a list of buttons to display.
{return} Db_FormFieldDefinition returns the updated form field definition object.
Sets a list of buttons to be displayed in the 3rd row of HTML field toolbar. Please refer TinyMCE documentation for details about buttons.

htmlContentCss() method

public Db_FormFieldDefinition htmlContentCss(string $url)
$url string specifies an URL of CSS file
{return} Db_FormFieldDefinition returns the updated form field definition object.
Sets a custom CSS file to be used to style HTML field content. The URL should be relative to LemonStand application root.

htmlCustomStyles() method

public Db_FormFieldDefinition htmlCustomStyles(string $styles)
$styles string specifies a semicolon-separated list of styles
{return} Db_FormFieldDefinition returns the updated form field definition object.
Sets a list of TinyMCE custom styles for a HTML field. Please refer TinyMCE documentation for details about custom styles.

htmlFontColors() method

public Db_FormFieldDefinition htmlFontColors(string $colors)
$colors string specifies a comma-separated list of colors: "FF00FF,FFFF00,000000"
{return} Db_FormFieldDefinition returns the updated form field definition object.
Specifies a list of TinyMCE font colors for a HTML field. Please refer TinyMCE documentation for details about font colors.

htmlFontSizes() method

public Db_FormFieldDefinition htmlFontSizes(string $sizes)
$sizes string specifies a comma-separated list of sizes
{return} Db_FormFieldDefinition returns the updated form field definition object.
Sets a list of TinyMCE font sizes for a HTML field. Please refer TinyMCE documentation for details about font sizes.

htmlFullWidht() method

public Db_FormFieldDefinition htmlFullWidht(boolean $full_width)

This method is deprecated. Use htmlFullWidth() method instead.

$full_width boolean determines whether the field should be full-width.
{return} Db_FormFieldDefinition returns the updated form field definition object.
Determines whether the HTML field should be full-width.

htmlFullWidth() method

public Db_FormFieldDefinition htmlFullWidth(boolean $full_width)
$full_width boolean determines whether the field should be full-width.
{return} Db_FormFieldDefinition returns the updated form field definition object.
Determines whether the HTML field should be full-width.

htmlPlugins() method

public Db_FormFieldDefinition htmlPlugins(string $plugins)
$plugins string a list of plugins to load.
{return} Db_FormFieldDefinition returns the updated form field definition object.
Adds a list of TinyMCE plugins for a HTML field. Please refer to TinyMCE documentation for details about plugins. By default the following plugins are loaded: paste, searchreplace, advlink, inlinepopups. This method adds plugin to the existing list.

htmlValidChildElements() method

public Db_FormFieldDefinition htmlValidChildElements(string $value)
$value string specifies a list of valid child elements, as text
{return} Db_FormFieldDefinition returns the updated form field definition object.
Sets a list of TinyMCE valid child elements for a HTML field. Please refer TinyMCE documentation for details about valid child elements.

htmlValidElements() method

public Db_FormFieldDefinition htmlValidElements(string $value)
$value string specifies a list of valid elements, as text.
{return} Db_FormFieldDefinition returns the updated form field definition object.
Sets a list of TinyMCE valid elements for a HTML field. Please refer TinyMCE documentation for details about valid elements.

imageThumbSize() method

public Db_FormFieldDefinition imageThumbSize(integer $size)
$size integer specifies the size.
{return} Db_FormFieldDefinition returns the updated form field definition object.
Sets thumbnail size (both width and height) for an image field.

language() method

public Db_FormFieldDefinition language(string $language)
$language string specifies the language name.
{return} Db_FormFieldDefinition returns the updated form field definition object.
Sets a language for code editor fields syntax highlighting. Supported languages are: css, html, javascript, json, php, xml.

nl2br() method

public Db_FormFieldDefinition nl2br(boolean $convert)
$convert boolean determines whether new lines should be converted to line breaks.
{return} Db_FormFieldDefinition returns the updated form field definition object.
Determines whether new lines in the field value should be converted to line breaks in a form preview. This method works only with text areas.

noAttachmentsLabel() method

public Db_FormFieldDefinition noAttachmentsLabel(string $text)
$text string specifies the message text.
{return} Db_FormFieldDefinition returns the updated form field definition object.
Sets a message to display in a file attachment field if there are no files attached.

noLabel() method

public Db_FormFieldDefinition noLabel()
{return} Db_FormFieldDefinition returns the updated form field definition object.
Hides the element form label.

noOptions() method

public Db_FormFieldDefinition noOptions(string $text)
$text string specifies the text to display.
{return} Db_FormFieldDefinition returns the updated form field definition object.
Sets a text to display in multi-relation fields in case if no options were selected.

optionsHtmlEncode() method

public Db_FormFieldDefinition optionsHtmlEncode(boolean $encode)
$encode boolean determines whether options should be encoded.
{return} Db_FormFieldDefinition returns the updated form field definition object.
Determines where options in a drop-down field should be HTML-encoded before they are displayed. By default options are always encoded, but you can disable this feature if you need the option to contain HTML tags which should be outputted as is.

optionsMethod() method

public Db_FormFieldDefinition optionsMethod(string $name)
$name string specifies the method name.
{return} Db_FormFieldDefinition returns the updated form field definition object.
Sets the common model's method name responsible for returning a list of options for a multi-option field. Allows to define a single method responsible for returning options for different drop-down, checkbox list and radio button form fields. The method should be defined as follows:
public method method_name($db_name, $key_value = -1) 
{
  if ($db_name == 'color')
    return array(33=>'Red', 34=>'Blue');

  return false;
}
The parameter passed to the method is the column name. The method should return options for the specified column or FALSE if the column should use default options. The second method parameter is the key value. Please see renderAs() method description for details about this parameter. The method must return an array of record identifiers and values.

optionStateMethod() method

public Db_FormFieldDefinition optionStateMethod(string $name)
$name string specifies the method name.
{return} Db_FormFieldDefinition returns the updated form field definition object.
Sets the common model's method name responsible for returning option state for a multi-option field. Allows to define a single method responsible for returning option state for different checkbox list and radio button form fields. The method should be defined as follows:
public method method_name($db_name, $value)
{
  if ($db_value == 'color')
    return $this->color == $value;
}
The method must return a boolean value determining the option state.

placeholder() method

public Db_FormFieldDefinition placeholder(mixed $placeholder, string $field_section=NULL)
$placeholder mixed specifies the placeholder (can be string or boolean, set to false to hide default date/datetime placeholders).
$field_section string specifies the field section the placeholder is for (used values: 'time' for time section of a datetime field).
{return} Db_FormFieldDefinition returns the updated form field definition object.
Sets the placeholder for the form field. Use the second parameter when setting the placeholder for multi-field form fields like datetime.
public function define_form_fields($context = null)
{
  //set placeholder for a text, textarea or date field
  $this->add_form_field('test_field')->placeholder('placeholder text here');
  //set placeholders for a datetime field
  $this->add_form_field('test_datetime')->placeholder('03/31/2012')->placeholder->('15:30:00', 'time');
}

previewComment() method

public Db_FormFieldDefinition previewComment(string $text)
$text string specifies the comment text.
{return} Db_FormFieldDefinition returns the updated form field definition object.
Sets the element comment for the form preview. By default the preview comment matches the regular form comment.

previewHelp() method

public Db_FormFieldDefinition previewHelp(string $help_string)
$help_string string specifies the help string.
{return} Db_FormFieldDefinition returns the updated form field definition object.
Specifies HTML help string to be displayed in a form preview.

previewLink() method

public Db_FormFieldDefinition previewLink(string $url)
$url string specifies the link URL.
{return} Db_FormFieldDefinition returns the updated form field definition object.
Sets an URL for the field preview link. If the URL is specified, the field value on the preview form turns into a link.

previewNoOptionsMessage() method

public Db_FormFieldDefinition previewNoOptionsMessage(string $message)
$message string specifies the message text.
{return} Db_FormFieldDefinition returns the updated form field definition object.
Sets a text to be displayed for a relation field on the preview form when the field has no related records.

previewNoRelation() method

public Db_FormFieldDefinition previewNoRelation()
{return} Db_FormFieldDefinition returns the updated form field definition object.
Determines whether the relation preview is hidden for a relation field on the preview form. Relations on preview forms have a link for previewing the related record. This method allows to disable this feature.

referenceDescriptionField() method

public Db_FormFieldDefinition referenceDescriptionField(string $expression)
$expression string specifies the SQL expression.
{return} Db_FormFieldDefinition returns the updated form field definition object.
Sets a SQL expression for fetching option descriptions in reference-type fields. Option descriptions are supported by the radio button and checkbox list fields. Specify the expression the parameter. The expression can be a table name or any SQL expression returning a scalar value, for example CONCAT: concat(login_name, ' (', first_name, ' ', last_name, ')')

referenceFilter() method

public Db_FormFieldDefinition referenceFilter(string $expression)
$expression string specifies an SQL expression. Example: status is not null and status = 1
{return} Db_FormFieldDefinition returns the updated form field definition object.
Sets SQL expression for filtering reference-type fields. Use this method to filter options for relation-based multi-value fields.

referenceSort() method

public Db_FormFieldDefinition referenceSort(string $expression)
$expression string specifies an SQL sorting expression.
{return} Db_FormFieldDefinition returns the updated form field definition object.
Sets a SQL expression for ordering options in reference-type fields. Usually you can use the referred table name as the SQL expression, for example:
$this->add_form_field('customer_group')->referenceSort('name asc');

renderAs() method

public Db_FormFieldDefinition renderAs(string $render_mode, array $options=array())
$render_mode string specifies the render mode.
$options array a list of render mode specific options.
{return} Db_FormFieldDefinition returns the updated form field definition object.
Specifies the field render mode. By default render modes are guessed automatically basing in the database column or relation types:
  • tinyint columns are rendered as checkboxes.
  • float, numeric and varchar columns are rendered as input TEXT elements.
  • textarea columns are rendered as input TEXT elements.
  • datetime columns are rendered as the datetime widget.
  • db_date columns are rendered as the date widget.
  • belongs_to relations are rendered as drop-down fields.
  • has_and_belongs_to_many relations are rendered as checkbox lists.
You can override the default render mode by passing a required mode constant to the first argument of this method. List of supported render mode constants:
  • frm_text - creates a text element.
  • frm_password - creates a password element.
  • frm_dropdown - creates a drop-down element.
  • frm_radio - creates radio buttons.
  • frm_checkbox - creates a checkbox.
  • frm_checkboxlist - creates a checkbox list.
  • frm_textarea - creates a textarea element.
  • frm_html - creates WYSIWYG editor field.
  • frm_code_editor - creates a code editor field.
  • frm_grid - creates a grid element. See gridColumns(), gridSettings() methods for details.
  • frm_datetime - creates a date/time field.
  • frm_date - creates a date field.
  • frm_onoffswitcher - creates a switcher element.
  • frm_record_finder - creates a record finder element.
  • frm_file_attachments - creates a file attachments widget. Note that you should use renderFilesAs() to specify how exactly the files should be displayed - as images, as a single image, or as a list of files.
  • frm_widget - creates a form widget.
Options for multi-option fields (drop-down menu, checkbox list, or radio-button list) based on relation columns generate the list of options automatically. If you want a non-relation column to be rendered as a multi-value field you should define additional public methods in the model class. First method is get_[column_name]_options(). It should return the list of available options. If this method is defined in the model, it will be used for fetching the available options even for relation columns. The method should return an associative array.
public function define_form_fields($context = null)
{
  $this->add_form_field('notification_mode')-;
}

public function get_notification_mode_options($key_index=-1)
{
  $options = array(
    'nobody'=>'Nobody',
    'authors'=>'Authors only',
    'all'=>'All users'
  );

  if ($key_index == -1)
   return $options;

  return isset($options[$key_index]) ? $options[$key_index] : null;
}
The method should accept the parameter specifying the key value. It is used for the preview form feature. If the value is -1 the method returns full list of options. If the value is not -1, it should return a label for the option corresponding the key value. If you are not going to use preview forms for the model, implementing this feature is not required and you can just return all options from the method. This method executes before the method specified in optionsMethod() method and overrides its result.
For radio-button and checkbox lists the method can also return item descriptions:
public function get_notification_mode_options($key_index=-1)
{
  return array(
    'nobody'=>array('Nobody'=>'Do not send new comment notifications.'),
    'authors'=>array('Authors only'=>'Send new comment notifications only to post author.'),
    'all'=>array('All users'=>'Notify all users who have permissions to receive blog notifications.')
  );
}
Radio-button and checkbox list fields require the get_[column_name]_option_state() method, which determines whether an option is checked. The method should accept a single argument - the option value and return a boolean value:
public function get_notification_mode_option_state($value)
{
  return $this->notification_mode == $value;
}
This method executes before the method specified in optionStateMethod() method and overrides its result.

renderFilesAs() method

public Db_FormFieldDefinition renderFilesAs(string $renderMode)
$renderMode string specifies the file list render mode value.
{return} Db_FormFieldDefinition returns the updated form field definition object.
Sets a render mode for a file attachment field. Supported render modes for file attachments are:
  • single_file - allows to upload a single file.
  • single_image - allows to upload a single image.
  • file_list - allows to upload multiple files.
  • image_list - allows to upload multiple images.
Example:
$this->add_form_field('files')->renderAs(frm_file_attachments)->renderFilesAs('file_list');
File columns should have a corresponding has_many relation referring to the Db_File class. See Db_File class for details about creating model file fields.

See Also

saveCallback() method

public Db_FormFieldDefinition saveCallback(string $callback)
$callback string a JavaScript function name
{return} Db_FormFieldDefinition returns the updated form field definition object.
Sets a JavaScript function name to be executed when a user clicks Save button on the HTML editor toolbar.

side() method

public Db_FormFieldDefinition side($side $side='full')
$side $side specifies the form side side.
{return} Db_FormFieldDefinition returns the updated form field definition object.
Sets the form side the field should be placed to. Supported values are left, right, full. The form side can be specified in add_form_field() method.

size() method

public Db_FormFieldDefinition size(string $size)
$size string specifies a size selector. Supported values are tiny, small, large, huge, giant.
{return} Db_FormFieldDefinition returns the updated form field definition object.
Sets a size of textarea fields.

titlePartial() method

public Db_FormFieldDefinition titlePartial(string $partial_name)
$partial_name string specifies the partial name or an absolute partial's file path.
{return} Db_FormFieldDefinition returns the updated form field definition object.
Specifies name of a partial to render below the form field caption. The partial file should be placed to the views directory of the controller which renders the form. Alternatively you can specify the absolute pat to the partial.

validation() method

public Phpr_ValidationRules validation()
{return} Phpr_ValidationRules returns the validation rule set object.
Returns the validation rule set object corresponding to the form field.