Fieldmanager
  • Package
  • Class
  • Tree
  • Todo

Packages

  • Fieldmanager
    • Context
    • Datasource
    • Field
    • Util
  • None

Classes

  • Fieldmanager_Autocomplete
  • Fieldmanager_Checkbox
  • Fieldmanager_Checkboxes
  • Fieldmanager_Colorpicker
  • Fieldmanager_Datepicker
  • Fieldmanager_DraggablePost
  • Fieldmanager_Field
  • Fieldmanager_Grid
  • Fieldmanager_Group
  • Fieldmanager_Hidden
  • Fieldmanager_Link
  • Fieldmanager_Media
  • Fieldmanager_Options
  • Fieldmanager_Password
  • Fieldmanager_Radios
  • Fieldmanager_RichTextArea
  • Fieldmanager_Select
  • Fieldmanager_TextArea
  • Fieldmanager_TextField

Class Fieldmanager_Field

Abstract base class containing core functionality for Fieldmanager fields.

Fields are UI elements that allow a person to interact with data.

Direct known subclasses

Fieldmanager_Autocomplete, Fieldmanager_Checkbox, Fieldmanager_Password, Fieldmanager_RichTextArea, Fieldmanager_TextArea, Fieldmanager_TextField, Fieldmanager_Colorpicker, Fieldmanager_Datepicker, Fieldmanager_DraggablePost, Fieldmanager_Grid, Fieldmanager_Group, Fieldmanager_Hidden, Fieldmanager_Media, Fieldmanager_Options

Indirect known subclasses

Fieldmanager_Checkboxes, Fieldmanager_Radios, Fieldmanager_Select

Abstract
Package: Fieldmanager\Field
Located at class-fieldmanager-field.php

Methods summary

public string
# form_element( mixed $value )

Parameters

$value
mixed
string[]|string the value of the element.

Returns

string
HTML for the element. Generate HTML for the form element itself. Generally should be just one tag, no wrappers.
public
# __construct( string $label = '', array $options = array() )

Superclass constructor, just populates options and sanity-checks common elements. It might also die, but only helpfully, to catch errors in development.

Superclass constructor, just populates options and sanity-checks common elements. It might also die, but only helpfully, to catch errors in development.

Parameters

$label
string
$label title of form field
$options
array
$options with keys matching vars of the field in use.
public
# set_options( string $label, array $options )

Build options into properties and throw errors if developers add an unsupported opt.

Build options into properties and throw errors if developers add an unsupported opt.

Parameters

$label
string
$label title of form field
$options
array
$options with keys matching vars of the field in use.

Throws

FM_Developer_Exception
if an option is set but not defined in this class or the child class.
FM_Developer_Exception
if an option is set but not public.
public string
# element_markup( array $values = array() )

Generates all markup needed for all form elements in this field. Could be called directly by a plugin or theme.

Generates all markup needed for all form elements in this field. Could be called directly by a plugin or theme.

Parameters

$values
array
$values the current values of this element, in a tree structure if the element has children.

Returns

string
HTML for all form elements.
public string
# single_element_markup( mixed $value = Null, boolean $is_proto = False )

Generate wrappers and labels for one form element. Is called by element_markup(), calls form_element().

Generate wrappers and labels for one form element. Is called by element_markup(), calls form_element().

Parameters

$value
mixed
$value the current value of this element.
$is_proto
boolean
$is_proto true to generate a prototype element for Javascript.

Returns

string
HTML for a single form element.

See

Fieldmanager_Field::element_markup()
Fieldmanager_Field::form_element()
public
# preload_alter_values( array $values )

Alter values before rendering

Alter values before rendering

Parameters

$values
array
$values
public string
# wrap_with_multi_tools( string $html, mixed $classes = array() )

Wrap a chunk of HTML with "remove" and "move" buttons if applicable.

Wrap a chunk of HTML with "remove" and "move" buttons if applicable.

Parameters

$html
string
$html HTML to wrap.
$classes

Returns

string
wrapped HTML.
public string
# get_form_name( mixed $multiple = "" )

Get HTML form name (e.g. questions[answer]).

Get HTML form name (e.g. questions[answer]).

Returns

string
form name
public array
# get_form_tree( )

Recursively build path to this element (e.g. array(grandparent, parent, this) )

Recursively build path to this element (e.g. array(grandparent, parent, this) )

Returns

array
of parents
public string
# get_element_id( )

Get the ID for the form element itself, uses $this->seq (e.g. which position is this element in). Relying on the element's ID for anything isn't a great idea since it can be rewritten in JS.

Get the ID for the form element itself, uses $this->seq (e.g. which position is this element in). Relying on the element's ID for anything isn't a great idea since it can be rewritten in JS.

Returns

string
ID for use in a form element.
public string
# get_element_key( )

Get the storage key for the form element.

Get the storage key for the form element.

Returns

string
public boolean
# is_repeatable( )

Is this element repeatable or does it have a repeatable ancestor?

Is this element repeatable or does it have a repeatable ancestor?

Returns

boolean
True if yes, false if no.
public boolean
# is_group( )

Is the current field a group?

Is the current field a group?

Returns

boolean
True if yes, false if no.
public mixed[]
# presave_all( mixed $values, mixed $current_values )

Presaves all elements in what could be a set of them, dispatches to $this->presave()

Presaves all elements in what could be a set of them, dispatches to $this->presave()

Returns

mixed[]
sanitized values

Input

mixed[] $values
public sanitized
# presave( mixed $value, mixed $current_value = array() )

Presave function, which handles sanitization and validation

Presave function, which handles sanitization and validation

Parameters

$value
mixed
$value If a single field expects to manage an array, it must override presave()
$current_value

Returns

sanitized
values.
public string
# get_element_attributes( )

Generates an HTML attribute string based on the value of $this->attributes.

Generates an HTML attribute string based on the value of $this->attributes.

Returns

string
attributes ready to insert into an HTML tag.

See

Fieldmanager_Field::$attributes
public string
# get_element_label( array $classes = array() )

Get an HTML label for this element.

Get an HTML label for this element.

Parameters

$classes
array
$classes extra CSS classes.

Returns

string
HTML label.
public string
# add_another( )

Generates HTML for the "Add Another" button.

Generates HTML for the "Add Another" button.

Returns

string
button HTML.
public string
# get_sort_handle( )

Return HTML for the sort handle (multi-tools); a separate function to override

Return HTML for the sort handle (multi-tools); a separate function to override

Returns

string
public string
# get_remove_handle( )

Return HTML for the remove handle (multi-tools); a separate function to override

Return HTML for the remove handle (multi-tools); a separate function to override

Returns

string
public string
# get_collapse_handle( )

Return HTML for the collapse handle (multi-tools); a separate function to override

Return HTML for the collapse handle (multi-tools); a separate function to override

Returns

string
public array
# get_extra_element_classes( )

Return extra element classes; overriden by some fields.

Return extra element classes; overriden by some fields.

Returns

array
public
# add_user_form( string $title = '' )

Add a form on user pages

Add a form on user pages

Parameters

$title
string
$title
public
# add_page_form( string $uniqid )

Add a form on a frontend page

Add a form on a frontend page

Parameters

$uniqid
string
$uniqid a unique identifier for this form

See

Fieldmanager_Context_Form
public
# add_term_meta_box( string $title, string|array $taxonomies, boolean $show_on_add = true, boolean $show_on_edit = true, integer $parent = '' )

Add fields to the term add/edit page

Add fields to the term add/edit page

Parameters

$title
string
$title
$taxonomies
string|array
$taxonomies The taxonomies on which to display this form
$show_on_add
boolean
$show_on_add Whether or not to show the fields on the add term form
$show_on_edit
boolean
$show_on_edit Whether or not to show the fields on the edit term form
$parent
integer
$parent Only show this field on child terms of this parent term ID

See

Fieldmanager_Context_Term
public
# add_meta_box( string $title, string|string[] $post_types, string $context = 'normal', string $priority = 'default' )

Add this field as a metabox to a post type

Add this field as a metabox to a post type

Parameters

$title
string
$title
$post_types
string|string[]
$post_type
$context
string
$context
$priority
string
$priority

See

Fieldmanager_Context_Post
public
# add_quickedit_box( string $title, string|string[] $post_types, string $column_display_callback, callable $column_title = '' )

Add this field to a post type's quick edit box.

Add this field to a post type's quick edit box.

Parameters

$title
string
$title
$post_types
string|string[]
$post_type
$column_display_callback
string
$column_title
$column_title
callable
$column_display_callback

See

Fieldmanager_Context_Quickedit
public
# add_submenu_page( string $parent_slug, mixed $page_title, mixed $menu_title = Null, mixed $capability = 'manage_options', mixed $menu_slug = Null )

Add this group to an options page

Add this group to an options page

Parameters

$parent_slug
string
$title
$page_title
$menu_title
$capability
$menu_slug
public
# activate_submenu_page( )

Activate this group in an already-added submenu page

Activate this group in an already-added submenu page

public
# _unauthorized_access( string $debug_message = '' )

Die violently. If self::$debug is true, throw an exception.

Die violently. If self::$debug is true, throw an exception.

Parameters

$debug_message
string
$debug_message

Returns


e.g. return _you_ into a void.
public
# _invalid_definition( string $debug_message = '' )

Die violently. If self::$debug is true, throw an exception.

Die violently. If self::$debug is true, throw an exception.

Parameters

$debug_message
string
$debug_message

Returns


e.g. return _you_ into a void.
public string
# escape( string $field, string $default = 'esc_html' )

Escape a field based on the function in the escape argument.

Escape a field based on the function in the escape argument.

Parameters

$field
string
$field The field to escape.
$default
string
$default The default function to use to escape the field. Optional. Defaults to esc_html()

Returns

string
The escaped field.

Magic methods summary

Properties summary

public static boolean $debug
#

If true, throw exceptions for illegal behavior

If true, throw exceptions for illegal behavior

public integer $limit
#

How many of these fields to display, 0 for no limit

How many of these fields to display, 0 for no limit

public integer $minimum_count
#

How many of these fields to display at a minimum, if $limit != 1. If $limit == $minimum_count, the "add another" button and the remove tool will be hidden.

How many of these fields to display at a minimum, if $limit != 1. If $limit == $minimum_count, the "add another" button and the remove tool will be hidden.

public integer $extra_elements
#

How many empty fields to display if $limit != 1 when the total fields in the loaded data + $extra_elements > $minimum_count.

How many empty fields to display if $limit != 1 when the total fields in the loaded data + $extra_elements > $minimum_count.

public string $add_more_label
#

Text for add more button

Text for add more button

public string $name
#

The name of the form element, As in 'foo' in <input name="foo" />

The name of the form element, As in 'foo' in <input name="foo" />

public string $label
#

Label to use for form element

Label to use for form element

public boolean $inline_label
#

If true, the label and the element will display on the same line. Some elements may not support this.

If true, the label and the element will display on the same line. Some elements may not support this.

public boolean $label_after_element
#

If true, the label will be displayed after the element.

If true, the label will be displayed after the element.

public string $description
#

Description for the form element

Description for the form element

public boolean $description_after_element
#

If true, the description will be displayed after the element.

If true, the description will be displayed after the element.

public string|boolean[] $attributes
#

Extra HTML attributes to apply to the form element. Use boolean true to apply a standalone attribute, e.g. 'required' => true

Extra HTML attributes to apply to the form element. Use boolean true to apply a standalone attribute, e.g. 'required' => true

public string $field_class
#

CSS class for form element

CSS class for form element

public boolean $one_label_per_item
#

Repeat the label for each element if $limit > 1

Repeat the label for each element if $limit > 1

public boolean $sortable
#

Allow draggable sorting if $limit > 1

Allow draggable sorting if $limit > 1

public string $label_element
#

HTML element to use for label

HTML element to use for label

public callable $sanitize
#

Function to use to sanitize input

Function to use to sanitize input

public callback[] $validate
#

Functions to use to validate input

Functions to use to validate input

public string|array $validation_rules
#

jQuery validation rule(s) used to validate this field, entered as a string or associative array. These rules will be automatically converted to the appropriate Javascript format. For more information see http://jqueryvalidation.org/documentation/

jQuery validation rule(s) used to validate this field, entered as a string or associative array. These rules will be automatically converted to the appropriate Javascript format. For more information see http://jqueryvalidation.org/documentation/

public string|array $validation_messages
#

jQuery validation messages used by the rule(s) defined for this field, entered as a string or associative array. These rules will be automatically converted to the appropriate Javascript format. Any messages without a corresponding rule will be ignored. For more information see http://jqueryvalidation.org/documentation/

jQuery validation messages used by the rule(s) defined for this field, entered as a string or associative array. These rules will be automatically converted to the appropriate Javascript format. Any messages without a corresponding rule will be ignored. For more information see http://jqueryvalidation.org/documentation/

public boolean $required
#

Makes the field required on WordPress context forms that already have built-in validation. This is necessary only for the fields used with the term add context.

Makes the field required on WordPress context forms that already have built-in validation. This is necessary only for the fields used with the term add context.

public string|null $data_type
#

Data type this element is used in, generally set internally

Data type this element is used in, generally set internally

public integer|null $data_id
#

ID for $this->data_type, eg $post->ID, generally set internally

ID for $this->data_type, eg $post->ID, generally set internally

public boolean $save_empty
#

If true, save empty elements to DB (if $this->limit != 1; single elements are always saved)

If true, save empty elements to DB (if $this->limit != 1; single elements are always saved)

public boolean $skip_save
#

Do not save this field (useful for fields which handle saving their own data)

Do not save this field (useful for fields which handle saving their own data)

public boolean $index
#

Save this field additionally to an index

Save this field additionally to an index

public boolean $serialize_data
#

Save the fields to their own keys (only works in some contexts). Default is true.

Save the fields to their own keys (only works in some contexts). Default is true.

public Fieldmanager_Datasource $datasource
#

Optionally generate field from datasource. Used by Fieldmanager_Autocomplete and Fieldmanager_Options.

Optionally generate field from datasource. Used by Fieldmanager_Autocomplete and Fieldmanager_Options.

public array[] $display_if
#

Field name and value on which to display element. Sample: $element->display_if = array( 'src' => 'display-if-src-element', 'value' => 'display-if-src-value' );

Field name and value on which to display element. Sample: $element->display_if = array( 'src' => 'display-if-src-element', 'value' => 'display-if-src-value' );

public string $add_more_position
#

Where the new item should to added ( top/bottom ) of the stack. Used by Add Another button "top|bottom"

Where the new item should to added ( top/bottom ) of the stack. Used by Add Another button "top|bottom"

public boolean $remove_default_meta_boxes
#

If true, remove any default meta boxes that are overridden by Fieldmanager fields

If true, remove any default meta boxes that are overridden by Fieldmanager fields

public string $template
#

Template The path to the field template

Template The path to the field template

public array $meta_boxes_to_remove
#

If $remove_default_meta_boxes is true, this array will be populated with the list of default meta boxes to remove

If $remove_default_meta_boxes is true, this array will be populated with the list of default meta boxes to remove

public mixed $default_value
#

Default value The default value for the field, if unset

Default value The default value for the field, if unset

public callable|null $index_filter
#

Function that parses an index value and returns an optionally modified value.

Function that parses an index value and returns an optionally modified value.

public string $input_type
#

Input type, mainly to support HTML5 input types.

Input type, mainly to support HTML5 input types.

public array $escape
#

Custom escaping for labels, descriptions, etc. Associative array of $field => $callable arguments, for example:

Custom escaping for labels, descriptions, etc. Associative array of $field => $callable arguments, for example:

'escape' => array( 'label' => 'wp_kses_post' )

public boolean $is_attachment
#

Whether or not this field is present on the attachment edit screen

Whether or not this field is present on the attachment edit screen

Fieldmanager API documentation generated by ApiGen 2.8.0