PHP Class PodsForm, pods

Show file Open project: pods-framework/pods Class Usage Examples

Public Properties

Property Type Description
$field string
$field_group string
$field_type string
$field_types array
$form_counter integer
$loaded array

Protected Properties

Property Type Description
$instance PodsForm

Public Methods

Method Description
admin_init ( ) Run admin_init methods for each field type
attributes ( $attributes, $name = null, $type = null, $options = null ) Output a field's attributes
block_field_types ( ) : array Get list of available text field types
clean ( $input, $noarray = false, $db_field = false ) Clean a value for use in class / id
comment ( string $name, string $message = null, array $options = null ) : string Output a Field Comment Paragraph
data ( $data, $name = null, $type = null, $options = null ) Output a field's data (for use with jQuery)
date_field_types ( ) : array Get list of available date field types
default_value ( $value, $type = 'text', $name = null, $options = null, $pod = null, $id = null ) Parse the default the value
delete ( string $type, integer $id = null, string $name = null, array $options = null, array $pod = null ) Delete the value from the DB
dependencies ( array $options, string $prefix = '' ) : string Setup dependency / exclusion classes
display ( $type, mixed $value = null, string $name = null, array $options = null, array $pod = null, integer $id = null, array $traverse = null ) Change the way the value of the field is displayed with Pods::get
field ( string $name, mixed $value, string $type = 'text', array $options = null, array $pod = null, integer $id = null ) : string Output a field
field_loader ( string $field_type, string $file = '' ) : string Autoload a Field Type's class
field_method ( ) : mixed Run a method from a Field Type's class
field_setup ( null $field = null, null $core_defaults = null, null $type = null ) : array | null Get options for a field and setup defaults
field_types ( ) : array Get a list of all available field types and include
fields_setup ( null $fields = null, null $core_defaults = null, boolean $single = false ) : array | null Get options for a field and setup defaults
file_field_types ( ) : array Get list of available file field types
init ( ) : PodsForm Singleton handling for a basic pods_form() request
label ( string $name, string $label, string $help = '', array $options = null ) : string Output a field's label
merge_attributes ( $attributes, $name = null, $type = null, $options = null, $classes = '' ) Merge attributes and handle classes
number_field_types ( ) : array Get list of available number field types
options ( $type, $options ) : array Setup options for a field and store them for later use
options_setup ( $type = null, $options = null ) : array | null Get options for a field type and setup defaults
permission ( $type, null $name = null, null $options = null, null $fields = null, null $pod = null, null $id = null, null $params = null ) Check if a user has permission to be editing a field
pre_save ( string $type, mixed $value, integer $id = null, string $name = null, array $options = null, array $fields = null, array $pod = null, object $params = null ) Change the value or perform actions after validation but before saving to the DB
prepare ( $type, $options ) : mixed | void Setup value preparation for sprintf
regex ( $type, $options ) : mixed | void Setup regex for JS / PHP
register_field_type ( string $type, string $file = null ) : array Add a new Pod field type
repeatable_field_types ( ) : array Get list of available repeatable field types
row ( string $name, mixed $value, string $type = 'text', array $options = null, array $pod = null, integer $id = null ) : string Output a row (label, field, and comment)
save ( string $type, mixed $value, integer $id = null, string $name = null, array $options = null, array $fields = null, array $pod = null, object $params = null ) Save the value to the DB
simple_tableless_objects ( ) : array Get list of available text field types
submit_button ( string $text = null, string $type = 'primary large', string $name = 'submit', boolean $wrap = true, array | string $other_attributes = null ) Returns a submit button, with provided text and appropriate class, copied from WP Core for use on the frontend
tableless_field_types ( ) : array Get list of available tableless field types
text_field_types ( ) : array Get list of available text field types
ui_options ( $type ) : array | null Get Admin options for a field type and setup defaults
validate ( string $type, mixed $value, string $name = null, array $options = null, array $fields = null, array $pod = null, integer $id = null, array | object $params = null ) Validate a value before it's saved
value ( $type, mixed $value = null, string $name = null, array $options = null, array $pod = null, integer $id = null, array $traverse = null ) Change the value of the field

Protected Methods

Method Description
field_db ( $name, $value = null, $options = null ) Output field type 'db'
field_hidden ( $name, $value = null, $options = null ) Output a hidden field

Private Methods

Method Description
__clone ( ) Prevent clones
__construct ( ) : PodsForm Master handler for all field / form methods

Method Details

admin_init() public method

Run admin_init methods for each field type
Since: 2.3
public admin_init ( )

attributes() public static method

Output a field's attributes
Since: 2.0
public static attributes ( $attributes, $name = null, $type = null, $options = null )

block_field_types() public static method

Get list of available text field types
Since: 2.3
public static block_field_types ( ) : array
return array Text field types

clean() public static method

Clean a value for use in class / id
Since: 2.0
public static clean ( $input, $noarray = false, $db_field = false )

comment() public static method

Output a Field Comment Paragraph
Since: 2.0
public static comment ( string $name, string $message = null, array $options = null ) : string
$name string Field name
$message string Field comments
$options array Field options
return string Comment HTML

data() public static method

Output a field's data (for use with jQuery)
Since: 2.0
public static data ( $data, $name = null, $type = null, $options = null )

date_field_types() public static method

Get list of available date field types
Since: 2.3
public static date_field_types ( ) : array
return array Date field types

default_value() public static method

Parse the default the value
Since: 2.0
public static default_value ( $value, $type = 'text', $name = null, $options = null, $pod = null, $id = null )

delete() public static method

Delete the value from the DB
Since: 2.3
public static delete ( string $type, integer $id = null, string $name = null, array $options = null, array $pod = null )
$type string
$id integer
$name string
$options array
$pod array

dependencies() public static method

Setup dependency / exclusion classes
Since: 2.0
public static dependencies ( array $options, string $prefix = '' ) : string
$options array array( 'depends-on' => ..., 'excludes-on' => ...)
$prefix string
return string

display() public static method

Change the way the value of the field is displayed with Pods::get
Since: 2.0
public static display ( $type, mixed $value = null, string $name = null, array $options = null, array $pod = null, integer $id = null, array $traverse = null )
$value mixed
$name string
$options array
$pod array
$id integer
$traverse array

field() public static method

Output a field
Since: 2.0
public static field ( string $name, mixed $value, string $type = 'text', array $options = null, array $pod = null, integer $id = null ) : string
$name string Field name
$value mixed Field value
$type string Field type
$options array Field options
$pod array Pod data
$id integer Item ID
return string Field HTML

field_db() protected static method

Used for field names and other places where only [a-z0-9_] is accepted
Since: 2.0
protected static field_db ( $name, $value = null, $options = null )

field_hidden() protected static method

Output a hidden field
protected static field_hidden ( $name, $value = null, $options = null )

field_loader() public static method

Autoload a Field Type's class
Since: 2.0
public static field_loader ( string $field_type, string $file = '' ) : string
$field_type string Field Type indentifier
$file string The Field Type class file location
return string

field_method() public static method

Run a method from a Field Type's class
Since: 2.0
public static field_method ( ) : mixed
return mixed

field_setup() public static method

Get options for a field and setup defaults
Since: 2.0
public static field_setup ( null $field = null, null $core_defaults = null, null $type = null ) : array | null
$field null
$core_defaults null
$type null
return array | null

field_types() public static method

Get a list of all available field types and include
Since: 2.3
public static field_types ( ) : array
return array Registered Field Types data

fields_setup() public static method

Get options for a field and setup defaults
Since: 2.0
public static fields_setup ( null $fields = null, null $core_defaults = null, boolean $single = false ) : array | null
$fields null
$core_defaults null
$single boolean
return array | null

file_field_types() public static method

Get list of available file field types
Since: 2.3
public static file_field_types ( ) : array
return array File field types

init() public static method

Singleton handling for a basic pods_form() request
Since: 2.3.5
public static init ( ) : PodsForm
return PodsForm

label() public static method

Output a field's label
Since: 2.0
public static label ( string $name, string $label, string $help = '', array $options = null ) : string
$name string Field name
$label string Label text
$help string Help text
$options array Field options
return string Label HTML

merge_attributes() public static method

Merge attributes and handle classes
Since: 2.0
public static merge_attributes ( $attributes, $name = null, $type = null, $options = null, $classes = '' )

number_field_types() public static method

Get list of available number field types
Since: 2.3
public static number_field_types ( ) : array
return array Number field types

options() public static method

Setup options for a field and store them for later use
Since: 2.0
public static options ( $type, $options ) : array
$type
$options
return array

options_setup() public static method

Get options for a field type and setup defaults
Since: 2.0
public static options_setup ( $type = null, $options = null ) : array | null
$type
return array | null

permission() public static method

Check if a user has permission to be editing a field
Since: 2.0
public static permission ( $type, null $name = null, null $options = null, null $fields = null, null $pod = null, null $id = null, null $params = null )
$type
$name null
$options null
$fields null
$pod null
$id null
$params null

pre_save() public static method

Change the value or perform actions after validation but before saving to the DB
Since: 2.0
public static pre_save ( string $type, mixed $value, integer $id = null, string $name = null, array $options = null, array $fields = null, array $pod = null, object $params = null )
$type string
$value mixed
$id integer
$name string
$options array
$fields array
$pod array
$params object

prepare() public static method

Setup value preparation for sprintf
Since: 2.0
public static prepare ( $type, $options ) : mixed | void
$type
$options
return mixed | void

regex() public static method

Setup regex for JS / PHP
Since: 2.0
public static regex ( $type, $options ) : mixed | void
$type
$options
return mixed | void

register_field_type() public static method

Add a new Pod field type
Since: 2.3
public static register_field_type ( string $type, string $file = null ) : array
$type string The new field type identifier
$file string The new field type class file location
return array Field Type data

repeatable_field_types() public static method

Get list of available repeatable field types
Since: 2.3
public static repeatable_field_types ( ) : array
return array Repeatable field types

row() public static method

Output a row (label, field, and comment)
Since: 2.0
public static row ( string $name, mixed $value, string $type = 'text', array $options = null, array $pod = null, integer $id = null ) : string
$name string Field name
$value mixed Field value
$type string Field type
$options array Field options
$pod array Pod data
$id integer Item ID
return string Row HTML

save() public static method

Save the value to the DB
Since: 2.3
public static save ( string $type, mixed $value, integer $id = null, string $name = null, array $options = null, array $fields = null, array $pod = null, object $params = null )
$type string
$value mixed
$id integer
$name string
$options array
$fields array
$pod array
$params object

simple_tableless_objects() public static method

Get list of available text field types
Since: 2.3
public static simple_tableless_objects ( ) : array
return array Text field types

submit_button() public static method

Returns a submit button, with provided text and appropriate class, copied from WP Core for use on the frontend
See also: get_submit_button
Since: 3.0
public static submit_button ( string $text = null, string $type = 'primary large', string $name = 'submit', boolean $wrap = true, array | string $other_attributes = null )
$text string The text of the button (defaults to 'Save Changes')
$type string The type of button. One of: primary, secondary, delete
$name string The HTML name of the submit button. Defaults to "submit". If no id attribute is given in $other_attributes below, $name will be used as the button's id.
$wrap boolean True if the output button should be wrapped in a paragraph tag, false otherwise. Defaults to true
$other_attributes array | string Other attributes that should be output with the button, mapping attributes to their values, such as array( 'tabindex' => '1' ). These attributes will be output as attribute="value", such as tabindex="1". Defaults to no other attributes. Other attributes can also be provided as a string such as 'tabindex="1"', though the array format is typically cleaner.

tableless_field_types() public static method

Get list of available tableless field types
Since: 2.3
public static tableless_field_types ( ) : array
return array Tableless field types

text_field_types() public static method

Get list of available text field types
Since: 2.3
public static text_field_types ( ) : array
return array Text field types

ui_options() public static method

Get Admin options for a field type and setup defaults
Since: 2.0
public static ui_options ( $type ) : array | null
$type
return array | null

validate() public static method

Validate a value before it's saved
Since: 2.0
public static validate ( string $type, mixed $value, string $name = null, array $options = null, array $fields = null, array $pod = null, integer $id = null, array | object $params = null )
$type string
$value mixed
$name string
$options array
$fields array
$pod array
$id integer
$params array | object

value() public static method

Change the value of the field
Since: 2.3
public static value ( $type, mixed $value = null, string $name = null, array $options = null, array $pod = null, integer $id = null, array $traverse = null )
$value mixed
$name string
$options array
$pod array
$id integer
$traverse array

Property Details

$field static public property

static public string $field
return string

$field_group static public property

static public string $field_group
return string

$field_type static public property

static public string $field_type
return string

$field_types static public property

static public array $field_types
return array

$form_counter static public property

static public int $form_counter
return integer

$instance protected static property

protected static PodsForm $instance
return PodsForm

$loaded static public property

static public array $loaded
return array