PHP Class Formo_Core_Formo

ファイルを表示 Open project: bmidget/kohana-formo

Public Methods

Method Description
__construct ( array $array = NULL ) : Formo Set up new field
__get ( mixed $key ) : mixed Return a field Retuns NULL if the field doesn't exist
__invoke ( ) : string Convert just the input to html
__isset ( mixed $key ) : boolean Determine whether a field exists
__set ( mixed $key, mixed $value ) : void Add a field to another field. Only works with Formo objects
__toString ( ) : string Render the Formo object
add ( mixed $alias, mixed $driver = NULL, mixed $value = NULL, array $opts = NULL ) : void Add a field or subform to a field or form
add_class ( mixed $class ) : Formo Add a class tag to the field
add_rule ( mixed $rule, array $params = NULL ) : Formo Add a single rule
add_rule_fields ( array $rule, array $fields ) : void Add a single rule accross a group of fields
add_rules ( array $array ) : void Add multiple rules at a time
add_rules_fields ( array $array ) : Formo Add rules for multiple fields
alias ( ) : string Helper method to return the field's alias
as_array ( mixed $value = NULL, boolean $recursive = FALSE ) : array Return the field or form as an array
attr ( mixed $get, mixed $set = NULL ) : Formo Set an html attribute or attributes
attr_fields ( array $array ) : void Set attributes for a set of fields
blueprint_deleted ( $field = NULL )
blueprint_dynamic ( $field = NULL )
callback ( mixed $type, array $callbacks = NULL ) : Formo Setup callback or callbacks
close ( ) : string Return the field's closing tag
copy_blueprint ( array $vals = [] ) : Formo Create a copy from form or group object
driver ( mixed $func, array $args = NULL ) : mixed Run a method through a field's driver
error ( mixed $message = NULL, array $params = [] ) : mixed Get or set a field error
errors ( array &$array = NULL ) : array Get field errors
factory ( array $array = NULL ) : Formo Simple factory method
find ( mixed $alias, boolean $not_recursive = FALSE ) : mixed Find a field by its alias Returns NULL if field can't be found
flatten ( array &$array = NULL ) : Formo Flatten fields in a form
form ( array $array = NULL ) : Formo Helper method to return a form field
ftype ( array $array = [] )
get ( mixed $var, mixed $default = NULL ) : mixed Get a field attribute You can use Arr::path dot syntax to retrieve a value
html ( mixed $str = NULL ) : void Get or set HTML
input ( ) : string Convert just the input to html
label ( ) : void Return a field's label
load ( array $values = NULL, array $files = NULL ) : Formo Load an array of alias => value pairs into a form
merge ( mixed $property, array $array = NULL ) : Formo Merge a field with an array value with a new array
merge_fields ( array $array ) : Formo Merge properties for multiple fields
name ( ) : string Return a field's HTML 'name' tag value
open ( ) : string Return a field's HTML opening tag
order ( mixed $field, mixed $new_order = NULL, mixed $relative_field = NULL ) : Formo Reorder a field or multiple fields
orm ( mixed $method, array $vals = NULL ) : Formo (Deprecated) Run a method through the ORM driver
pad_blueprint ( $count_or_vals = 1 ) : Formo Pad group with number of blueprints
parent ( mixed $group_or_form = FALSE ) : mixed Find a field's parent If TRUE passed, find the field's parent (return that field if it is the parent)
remove ( mixed $alias ) : Formo Remove a field or fields from a form
remove_class ( mixed $class ) : Formo Remove a class or classes
remove_rule ( mixed $rule ) : Formo Remove a rule or rules from a field.
remove_rules ( array $array ) : void Remove multiple rules at a time
remove_rules_fields ( mixed $array ) : void Remove rules for multiple fields
render ( $template = NULL ) : string Render a field from its view file
render_opts ( ) : string Render options (used for select, checkboxes, radios)
reset ( ) : Formo Reset field values to their original values
sent ( array $input_array = NULL ) : boolean Determine whether a form or field has been sent
set ( mixed $var, mixed $val = NULL ) : void Set a value for a field's attribute You can use Arr::set_path's dot-syntax to set an attribute
set_fields ( array $array, boolean $not_recursive = TRUE ) : void Set variables for a set of fields
set_var_fields ( mixed $var, array $array, boolean $not_recursive = TRUE ) : void Set a single variable for a set of fields
subform ( mixed $alias, array $fields, array $order = NULL, string $driver = 'group' ) : Formo Create a subform from an array list of fields already in a form
title ( ) : string Return a field's title
to_array ( array $attributes = NULL ) : array Use for casting to json or for sending form objects across an api
val ( $new_val = NULL, $force_new = FALSE )
validate ( ) : boolean Validate all fields and return whether form passed validation
validation ( array $array = NULL ) : Validation Fetch a validation object from a field or form
validation_errors ( Kohana_Validation $validation ) : mixed Format error messages from a validation object according to Formo's formatting rules

Method Details

__construct() public method

Set up new field
public __construct ( array $array = NULL ) : Formo
$array array (default: NULL)
return Formo obj

__get() public method

Return a field Retuns NULL if the field doesn't exist
public __get ( mixed $key ) : mixed
$key mixed
return mixed

__invoke() public method

Convert just the input to html
public __invoke ( ) : string
return string

__isset() public method

Determine whether a field exists
public __isset ( mixed $key ) : boolean
$key mixed
return boolean

__set() public method

Add a field to another field. Only works with Formo objects
public __set ( mixed $key, mixed $value ) : void
$key mixed
$value mixed
return void

__toString() public method

Render the Formo object
public __toString ( ) : string
return string

add() public method

Add a field or subform to a field or form
public add ( mixed $alias, mixed $driver = NULL, mixed $value = NULL, array $opts = NULL ) : void
$alias mixed
$driver mixed (default: NULL)
$value mixed (default: NULL)
$opts array (default: NULL)
return void

add_class() public method

Add a class tag to the field
public add_class ( mixed $class ) : Formo
$class mixed
return Formo obj

add_rule() public method

Add a single rule
public add_rule ( mixed $rule, array $params = NULL ) : Formo
$rule mixed (as array like Validation::rules() or string like Validation::rule())
$params array (only used if $rule isn't an array, default: NULL)
return Formo obj

add_rule_fields() public method

Add a single rule accross a group of fields
public add_rule_fields ( array $rule, array $fields ) : void
$rule array
$fields array
return void

add_rules() public method

Add multiple rules at a time
public add_rules ( array $array ) : void
$array array
return void

add_rules_fields() public method

Add rules for multiple fields
public add_rules_fields ( array $array ) : Formo
$array array
return Formo obj

alias() public method

Helper method to return the field's alias
public alias ( ) : string
return string

as_array() public method

Return the field or form as an array
public as_array ( mixed $value = NULL, boolean $recursive = FALSE ) : array
$value mixed (default: NULL)
$recursive boolean (default: FALSE)
return array

attr() public method

Set an html attribute or attributes
public attr ( mixed $get, mixed $set = NULL ) : Formo
$get mixed
$set mixed (default: NULL)
return Formo obj

attr_fields() public method

Set attributes for a set of fields
public attr_fields ( array $array ) : void
$array array
return void

blueprint_deleted() public method

public blueprint_deleted ( $field = NULL )

blueprint_dynamic() public method

public blueprint_dynamic ( $field = NULL )

callback() public method

Setup callback or callbacks
public callback ( mixed $type, array $callbacks = NULL ) : Formo
$type mixed
$callbacks array
return Formo obj

close() public method

Return the field's closing tag
public close ( ) : string
return string

copy_blueprint() public method

Create a copy from form or group object
public copy_blueprint ( array $vals = [] ) : Formo
$vals array (default: array())
return Formo

driver() public method

Run a method through a field's driver
public driver ( mixed $func, array $args = NULL ) : mixed
$func mixed
$args array (default: NULL)
return mixed

error() public method

Get or set a field error
public error ( mixed $message = NULL, array $params = [] ) : mixed
$message mixed (default: NULL)
$params array (default: array())
return mixed

errors() public method

Get field errors
public errors ( array &$array = NULL ) : array
$array array
return array

factory() public static method

Simple factory method
public static factory ( array $array = NULL ) : Formo
$array array (default: NULL)
return Formo obj

find() public method

Find a field by its alias Returns NULL if field can't be found
public find ( mixed $alias, boolean $not_recursive = FALSE ) : mixed
$alias mixed
$not_recursive boolean (default: FALSE)
return mixed

flatten() public method

Flatten fields in a form
public flatten ( array &$array = NULL ) : Formo
$array array
return Formo obj

form() public static method

Helper method to return a form field
public static form ( array $array = NULL ) : Formo
$array array (default: NULL)
return Formo obj

ftype() public method

public ftype ( array $array = [] )
$array array

get() public method

Get a field attribute You can use Arr::path dot syntax to retrieve a value
public get ( mixed $var, mixed $default = NULL ) : mixed
$var mixed
$default mixed (default: NULL)
return mixed

html() public method

Get or set HTML
public html ( mixed $str = NULL ) : void
$str mixed
return void

input() public method

Convert just the input to html
public input ( ) : string
return string

label() public method

Return a field's label
public label ( ) : void
return void

load() public method

Load an array of alias => value pairs into a form
public load ( array $values = NULL, array $files = NULL ) : Formo
$values array
$files array
return Formo

merge() public method

Merge a field with an array value with a new array
public merge ( mixed $property, array $array = NULL ) : Formo
$property mixed
$array array (default: NULL)
return Formo obj

merge_fields() public method

Merge properties for multiple fields
public merge_fields ( array $array ) : Formo
$array array
return Formo obj

name() public method

Return a field's HTML 'name' tag value
public name ( ) : string
return string

open() public method

Return a field's HTML opening tag
public open ( ) : string
return string

order() public method

Reorder a field or multiple fields
public order ( mixed $field, mixed $new_order = NULL, mixed $relative_field = NULL ) : Formo
$field mixed
$new_order mixed (default: NULL)
$relative_field mixed (default: NULL)
return Formo obj

orm() public method

(Deprecated) Run a method through the ORM driver
public orm ( mixed $method, array $vals = NULL ) : Formo
$method mixed
$vals array (default: NULL)
return Formo obj

pad_blueprint() public method

Pad group with number of blueprints
public pad_blueprint ( $count_or_vals = 1 ) : Formo
return Formo

parent() public method

Find a field's parent If TRUE passed, find the field's parent (return that field if it is the parent)
public parent ( mixed $group_or_form = FALSE ) : mixed
$group_or_form mixed (default: FALSE)
return mixed

remove() public method

Remove a field or fields from a form
public remove ( mixed $alias ) : Formo
$alias mixed
return Formo obj

remove_class() public method

Remove a class or classes
public remove_class ( mixed $class ) : Formo
$class mixed
return Formo obj

remove_rule() public method

Remove a rule or rules from a field.
public remove_rule ( mixed $rule ) : Formo
$rule mixed (default: NULL)
return Formo obj

remove_rules() public method

Remove multiple rules at a time
public remove_rules ( array $array ) : void
$array array
return void

remove_rules_fields() public method

Remove rules for multiple fields
public remove_rules_fields ( mixed $array ) : void
$array mixed
return void

render() public method

Render a field from its view file
public render ( $template = NULL ) : string
return string

render_opts() public method

Render options (used for select, checkboxes, radios)
public render_opts ( ) : string
return string

reset() public method

Reset field values to their original values
public reset ( ) : Formo
return Formo obj

sent() public method

Determine whether a form or field has been sent
public sent ( array $input_array = NULL ) : boolean
$input_array array (default: NULL)
return boolean

set() public method

Set a value for a field's attribute You can use Arr::set_path's dot-syntax to set an attribute
public set ( mixed $var, mixed $val = NULL ) : void
$var mixed
$val mixed (default: NULL)
return void

set_fields() public method

Set variables for a set of fields
public set_fields ( array $array, boolean $not_recursive = TRUE ) : void
$array array
$not_recursive boolean (default: TRUE)
return void

set_var_fields() public method

Set a single variable for a set of fields
public set_var_fields ( mixed $var, array $array, boolean $not_recursive = TRUE ) : void
$var mixed
$array array
$not_recursive boolean (default: TRUE)
return void

subform() public method

Create a subform from an array list of fields already in a form
public subform ( mixed $alias, array $fields, array $order = NULL, string $driver = 'group' ) : Formo
$alias mixed
$fields array
$order array (default: NULL)
$driver string (default: 'group')
return Formo obj

title() public method

Return a field's title
public title ( ) : string
return string

to_array() public method

Use for casting to json or for sending form objects across an api
public to_array ( array $attributes = NULL ) : array
$attributes array
return array

val() public method

public val ( $new_val = NULL, $force_new = FALSE )

validate() public method

Validate all fields and return whether form passed validation
public validate ( ) : boolean
return boolean

validation() public method

Fetch a validation object from a field or form
public validation ( array $array = NULL ) : Validation
$array array (default: NULL)
return Validation obj

validation_errors() public method

Format error messages from a validation object according to Formo's formatting rules
public validation_errors ( Kohana_Validation $validation ) : mixed
$validation Kohana_Validation
return mixed