|
Db_FormFieldDefinition class
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 propertiesShow inherited properties.
Public methodsShow inherited methods.
Property details¶ addAttachmentLabel propertypublic string $addAttachmentLabel;
Specifies prompt message for a file attachment field.
¶ checkboxOnState propertypublic string $checkboxOnState;
Specifies value corresponding the on state of a checkbox field.
¶ comment propertypublic string $comment;
Specifies the element comment.
Comments are displayed on the form below or above the element.
See comment() method for details.
¶ commentHTML propertypublic boolean $commentHTML;
Determines whether the comment contains HTML tags.
See comment() method for details.
¶ commentPosition propertypublic string $commentPosition;
Specifies the comment position.
Supported values are above or below.
See comment() method for details.
¶ commentTooltip propertypublic string $commentTooltip;
Specifies a tooltip text for the field comment.
¶ cssClasses propertypublic string $cssClasses;
Specifies CSS class to be applied to the field container element.
¶ cssClassName propertypublic string $cssClassName;
Specifies CSS class to be applied to the field LI element.
¶ dbName propertypublic string $dbName;
Specifies the database column or relation name.
¶ disabled propertypublic boolean $disabled;
Determines whether the field is disabled on the form.
¶ emptyOption propertypublic string $emptyOption;
Specifies a label corresponding an empty option for drop-down elements.
See emptyOption() method for details.
¶ fileDownloadBaseUrl propertypublic string $fileDownloadBaseUrl;
Sets a base URL for file links for a file attachments field.
¶ formElementPartial propertypublic string $formElementPartial;
Specifies name of a partial to render instead of the normal form field markup.
¶ formSide propertypublic string $formSide;
Specifies the form side the element should be placed to.
Supported values are left, right, full.
¶ gridColumns propertypublic array $gridColumns;
Defines column configuration for a grid field.
See gridColumns() method for details.
¶ gridSettings propertypublic array $gridSettings;
Defines configuration of a grid field.
See gridSettings() method for details.
¶ hideContent propertypublic boolean $hideContent;
Determines a text area content should be hidden in a form.
¶ htmlAllowMoreColors propertypublic boolean $htmlAllowMoreColors;
Specifies whether TinyMCE "more colors" feature is available for a HTML field.
¶ htmlBackgroundColors propertypublic string $htmlBackgroundColors;
Specifies a list of TinyMCE background colors for a HTML field.
¶ htmlBlockFormats propertypublic string $htmlBlockFormats;
Specifies a list of TinyMCE block formats for a HTML field.
¶ htmlButtons1 propertypublic string $htmlButtons1;
Specifies a list of TinyMCE toolbar #1 buttons for a HTML field.
¶ htmlButtons2 propertypublic string $htmlButtons2;
Specifies a list of TinyMCE toolbar #2 buttons for a HTML field.
¶ htmlButtons3 propertypublic string $htmlButtons3;
Specifies a list of TinyMCE toolbar #3 buttons for a HTML field.
¶ htmlContentCss propertypublic 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 propertypublic string $htmlCustomStyles;
Specifies a list of TinyMCE custom styles for a HTML field.
¶ htmlFontColors propertypublic string $htmlFontColors;
Specifies a list of TinyMCE font colors for a HTML field.
¶ htmlFontSizes propertypublic string $htmlFontSizes;
Specifies a list of TinyMCE font sizes for a HTML field.
¶ htmlFullWidth propertypublic boolean $htmlFullWidth;
Determines whether the HTML field should be full-width.
¶ htmlPlugins propertypublic string $htmlPlugins;
Specifies a list of TinyMCE plugins for a HTML field.
¶ htmlValidChildElements propertypublic string $htmlValidChildElements;
Specifies a list of TinyMCE valid child elements for a HTML field.
¶ htmlValidElements propertypublic string $htmlValidElements;
Specifies a list of TinyMCE valid elements for a HTML field.
¶ imageThumbSize propertypublic integer $imageThumbSize;
Specifies thumbnail size (both width and height) for an image field.
¶ language propertypublic string $language;
Specifies language for a code editor field.
See language() method for details.
¶ nl2br propertypublic string $nl2br;
Specifies whether new lines in the field value should be converted to line breaks in a form preview.
¶ noAttachmentsLabel propertypublic string $noAttachmentsLabel;
Specifies a message to display in a file attachment field if there are no files attached.
¶ noLabel propertypublic boolean $noLabel;
Determines whether the element form label is invisible.
¶ noOptions propertypublic string $noOptions;
Specifies a text to display in multi-relation fields in case if no options were selected.
¶ optionsHtmlEncode propertypublic boolean $optionsHtmlEncode;
Determines where options in a drop-down field should be HTML-encoded before they are displayed.
¶ optionsMethod propertypublic 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 propertypublic 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 propertypublic 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 propertypublic string $previewHelp;
Specifies HTML help string to be displayed in a form preview.
¶ previewLink propertypublic string $previewLink;
Specifies an URL for the field preview link.
¶ previewNoRelation propertypublic boolean $previewNoRelation;
Determines whether the relation preview is available for a relation field on the preview form.
¶ referenceDescriptionField propertypublic string $referenceDescriptionField;
Specifies a SQL expression for fetching option descriptions in reference-type fields.
See referenceDescriptionField() method for details.
¶ referenceFilter propertypublic string $referenceFilter;
Specifies a SQL expression for filtering reference-type fields.
See referenceFilter() method for details.
¶ referenceSort propertypublic string $referenceSort;
Specifies a SQL expression for ordering options in reference-type fields.
See referenceSort() method for details.
¶ relationPreviewNoOptions propertypublic string $relationPreviewNoOptions;
Specifies a text to be displayed for a relation field on the preview form when the field has no related records.
¶ renderFilesAs propertypublic string $renderFilesAs;
Specifies a render mode for a file attachment field.
See renderFilesAs() method for details.
¶ renderMode propertypublic string $renderMode;
Specifies the field render mode.
See renderAs() method for details
about supported render modes.
¶ renderOptions propertypublic array $renderOptions;
Specifies rendering options for complex fields and widgets.
See documentation for a specific field for details.
¶ saveCallback propertypublic string $saveCallback;
Specifies JavaScript function name to be executed when Save button is clicked in a HTML field.
¶ size propertypublic string $size;
Specifies a size of textarea fields.
See size() method for details.
¶ titlePartial propertypublic string $titlePartial;
Specifies name of a partial to render below the form field caption.
Method details¶ addDocumentLabel() methodpublic Db_FormFieldDefinition addDocumentLabel(string $label)
Sets prompt message for a file attachment field.
¶ checkboxOnState() methodpublic Db_FormFieldDefinition checkboxOnState(string $value)
Sets value corresponding the on state of a checkbox field.
¶ comment() methodpublic Db_FormFieldDefinition comment(string $text, string $position='below', bool $commentHTML=false)
Sets the element comment.
Comments are displayed on the form below or above the element.
¶ commentTooltip() methodpublic Db_FormFieldDefinition commentTooltip(string $help_string)
Specifies a tooltip text for the field comment.
¶ cssClasses() methodpublic Db_FormFieldDefinition cssClasses(string $classes)
Sets CSS class to be applied to the field container element.
¶ cssClassName() methodpublic Db_FormFieldDefinition cssClassName(string $classes)
Sets a CSS class name to apply to the field LI element.
¶ disabled() methodpublic Db_FormFieldDefinition disabled()
Disables the form field.
¶ emptyOption() methodpublic Db_FormFieldDefinition emptyOption(string $text)
Specifies a label corresponding an empty option for drop-down elements
Use this method for the default empty option like <please select color>.
¶ fileDownloadBaseUrl() methodpublic Db_FormFieldDefinition fileDownloadBaseUrl(string $url)
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() methodpublic Db_FormFieldDefinition formElementPartial(string $partial_name)
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() methodpublic Db_ColumnDefinition getColDefinition()
Returns the model column definition corresponding the form field.
¶ gridColumns() methodpublic Db_FormFieldDefinition gridColumns(array $columns)
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() methodpublic Db_FormFieldDefinition gridSettings(array $settings)
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() methodpublic Db_FormFieldDefinition hideContent()
Hides a text area content in a form.
¶ htmlAllowMoreColors() methodpublic Db_FormFieldDefinition htmlAllowMoreColors(string $allow)
This option enables you to disable the "more colors" link in a HTML field for text and background color menus.
¶ htmlBackgroundColors() methodpublic Db_FormFieldDefinition htmlBackgroundColors(string $colors)
Sets a list of TinyMCE background colors for a HTML field.
Please refer TinyMCE documentation for details about background colors.
¶ htmlBlockFormats() methodpublic Db_FormFieldDefinition htmlBlockFormats(string $formats)
Sets a list of TinyMCE block formats for a HTML field.
Please refer TinyMCE documentation for details about block formats.
¶ htmlButtons1() methodpublic Db_FormFieldDefinition htmlButtons1(string $buttons)
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() methodpublic Db_FormFieldDefinition htmlButtons2(string $buttons)
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() methodpublic Db_FormFieldDefinition htmlButtons3(string $buttons)
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() methodpublic Db_FormFieldDefinition htmlContentCss(string $url)
Sets a custom CSS file to be used to style HTML field content.
The URL should be relative to LemonStand application root.
¶ htmlCustomStyles() methodpublic Db_FormFieldDefinition htmlCustomStyles(string $styles)
Sets a list of TinyMCE custom styles for a HTML field.
Please refer TinyMCE documentation for details about custom styles.
¶ htmlFontColors() methodpublic Db_FormFieldDefinition htmlFontColors(string $colors)
Specifies a list of TinyMCE font colors for a HTML field.
Please refer TinyMCE documentation for details about font colors.
¶ htmlFontSizes() methodpublic Db_FormFieldDefinition htmlFontSizes(string $sizes)
Sets a list of TinyMCE font sizes for a HTML field.
Please refer TinyMCE documentation for details about font sizes.
¶ htmlFullWidht() methodpublic Db_FormFieldDefinition htmlFullWidht(boolean $full_width)
This method is deprecated. Use htmlFullWidth() method instead.
Determines whether the HTML field should be full-width.
¶ htmlFullWidth() methodpublic Db_FormFieldDefinition htmlFullWidth(boolean $full_width)
Determines whether the HTML field should be full-width.
¶ htmlPlugins() methodpublic Db_FormFieldDefinition htmlPlugins(string $plugins)
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() methodpublic Db_FormFieldDefinition htmlValidChildElements(string $value)
Sets a list of TinyMCE valid child elements for a HTML field.
Please refer TinyMCE documentation for details about valid child elements.
¶ htmlValidElements() methodpublic Db_FormFieldDefinition htmlValidElements(string $value)
Sets a list of TinyMCE valid elements for a HTML field.
Please refer TinyMCE documentation for details about valid elements.
¶ imageThumbSize() methodpublic Db_FormFieldDefinition imageThumbSize(integer $size)
Sets thumbnail size (both width and height) for an image field.
¶ language() methodpublic Db_FormFieldDefinition language(string $language)
Sets a language for code editor fields syntax highlighting.
Supported languages are: css, html, javascript, json, php, xml.
¶ nl2br() methodpublic Db_FormFieldDefinition nl2br(boolean $convert)
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() methodpublic Db_FormFieldDefinition noAttachmentsLabel(string $text)
Sets a message to display in a file attachment field if there are no files attached.
¶ noLabel() methodpublic Db_FormFieldDefinition noLabel()
Hides the element form label.
¶ noOptions() methodpublic Db_FormFieldDefinition noOptions(string $text)
Sets a text to display in multi-relation fields in case if no options were selected.
¶ optionsHtmlEncode() methodpublic Db_FormFieldDefinition optionsHtmlEncode(boolean $encode)
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() methodpublic Db_FormFieldDefinition optionsMethod(string $name)
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; } ¶ optionStateMethod() methodpublic Db_FormFieldDefinition optionStateMethod(string $name)
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; } ¶ placeholder() methodpublic Db_FormFieldDefinition placeholder(mixed $placeholder, string $field_section=NULL)
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() methodpublic Db_FormFieldDefinition previewComment(string $text)
Sets the element comment for the form preview.
By default the preview comment matches the regular form comment.
¶ previewHelp() methodpublic Db_FormFieldDefinition previewHelp(string $help_string)
Specifies HTML help string to be displayed in a form preview.
¶ previewLink() methodpublic Db_FormFieldDefinition previewLink(string $url)
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() methodpublic Db_FormFieldDefinition previewNoOptionsMessage(string $message)
Sets a text to be displayed for a relation field on the preview form when the field has no related records.
¶ previewNoRelation() methodpublic Db_FormFieldDefinition previewNoRelation()
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() methodpublic Db_FormFieldDefinition referenceDescriptionField(string $expression)
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() methodpublic Db_FormFieldDefinition referenceFilter(string $expression)
Sets SQL expression for filtering reference-type fields.
Use this method to filter options for relation-based multi-value fields.
¶ referenceSort() methodpublic Db_FormFieldDefinition referenceSort(string $expression)
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() methodpublic Db_FormFieldDefinition renderAs(string $render_mode, array $options=array())
Specifies the field render mode.
By default render modes are guessed automatically basing in the database column or relation types:
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; } 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.') ); } public function get_notification_mode_option_state($value) { return $this->notification_mode == $value; } ¶ renderFilesAs() methodpublic Db_FormFieldDefinition renderFilesAs(string $renderMode)
Sets a render mode for a file attachment field.
Supported render modes for file attachments are:
$this->add_form_field('files')->renderAs(frm_file_attachments)->renderFilesAs('file_list'); See Also¶ saveCallback() methodpublic Db_FormFieldDefinition saveCallback(string $callback)
Sets a JavaScript function name to be executed when a user clicks Save button on the HTML editor toolbar.
¶ side() methodpublic Db_FormFieldDefinition side($side $side='full')
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() methodpublic Db_FormFieldDefinition size(string $size)
Sets a size of textarea fields.
¶ titlePartial() methodpublic Db_FormFieldDefinition titlePartial(string $partial_name)
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() methodpublic Phpr_ValidationRules validation()
Returns the validation rule set object corresponding to the form field.
|