PHP Class Form_Basic, atk4

Author: Romans ([email protected])
Inheritance: extends View, implements ArrayAccess
Mostrar archivo Open project: atk4/atk4

Public Properties

Property Type Description
$app App_Web
$bail_out null | boolean If this is true, we won't load data or submit or validate anything.
$data array Afterwards fields will link to $this->data, so changing $this->data['fld_name'] would actually affect field's value. You should use $this->set() and $this->get() to read/write individual field values. You should use $this->setStaticSource() to load values from hash, BUT - AAAAAAAAAA: this array is no more!!!
$default_controller Class name of default controller
$default_exception Class name of default exception
$errors array Here we will have a list of errors occured in the form, when we tried to submit it. field_name => error
$js_widget JS widget name
$js_widget_arguments JS widget options
$layout View Template of layout if form has one.
$owner View
$search_for_field_spots Normally form fields are inserted using a form template. If you.
$template_chunks array Those templates will be used when rendering form and fields.
$validator Validator object

Protected Properties

Property Type Description
$ajax_submits array Contains AJAX instances assigned to buttons.
$conditions array
$get_field null | string If condition was passed to a form through GET, contains a GET field name.
$loaded_from_db boolean true - update() will try updating existing row. false - it would insert new.

Public Methods

Method Description
addButton ( $label = 'Button', $name = null )
addClass ( $class )
addField ( AbstractView | array | string $type, AbstractView | array | string $options = null, string $caption = null, string $attr = null ) : Form_Field Adds field in form.
addSeparator ( $class = '', $attr = [] )
addSubmit ( $label = 'Save', $name = null )
afterAdd ( $p, $c )
defaultTemplate ( $template = null, $tag = null )
displayError ( $field = null, $msg = null )
error ( string $field, string $text = null ) Adds error message to form field.
get ( $field = null )
getAllFields ( )
grabTemplateChunk ( $name )
hasField ( $name )
importFields ( Model $model, array | string | boolean $fields = UNDEFINED ) Imports model fields in form by using form controller.
init ( ) }}}
isClicked ( $name )
isLoadedFromDB ( )
isSubmitted ( )
lateSubmit ( )
loadData ( )
offsetExists ( $name ) {{{ ArrayAccess support
offsetGet ( $name )
offsetSet ( $name, $val )
offsetUnset ( $name )
onSubmit ( $callback )
render ( )
save ( )
set ( $field_or_array, $value = UNDEFINED ) * temporarily disabled. TODO: will be implemented with abstract datatype function setSource($table,$db_fields=null){ if(is_null($db_fields)){ $db_fields=array(); foreach($this->elements as $key=>$el){ if(!($el instanceof Form_Field))continue; if($el->no_save)continue; $db_fields[]=$key; } } $this->dq = $this->app->db->dsql() ->table($table) ->field('*',$table) ->limit(1); return $this; }
setFieldError ( $field, $name ) * external error management
setLayout ( $template )
showAjaxError ( object $field, string $msg ) Should show error in field. Override this method to change form default alert.
submitted ( )
update ( ) * obsolete in 4.3 - use save()
validate ( $rule )

Protected Methods

Method Description
getChunks ( )

Method Details

addButton() public method

public addButton ( $label = 'Button', $name = null )

addClass() public method

Deprecation: 4.3.2 Will be removed in 4.4
public addClass ( $class )

addField() public method

Adds field in form.
public addField ( AbstractView | array | string $type, AbstractView | array | string $options = null, string $caption = null, string $attr = null ) : Form_Field
$type AbstractView | array | string
$options AbstractView | array | string
$caption string
$attr string Deprecated argument
return Form_Field

addSeparator() public method

public addSeparator ( $class = '', $attr = [] )

addSubmit() public method

public addSubmit ( $label = 'Save', $name = null )

afterAdd() public method

public afterAdd ( $p, $c )

defaultTemplate() public method

public defaultTemplate ( $template = null, $tag = null )

displayError() public method

public displayError ( $field = null, $msg = null )

error() public method

Adds error message to form field.
public error ( string $field, string $text = null )
$field string
$text string

get() public method

public get ( $field = null )

getAllFields() public method

public getAllFields ( )

getChunks() protected method

protected getChunks ( )

grabTemplateChunk() public method

public grabTemplateChunk ( $name )

hasField() public method

Deprecation: 4.3.2 use getElement() instead
public hasField ( $name )

importFields() public method

Imports model fields in form by using form controller.
public importFields ( Model $model, array | string | boolean $fields = UNDEFINED )
$model Model
$fields array | string | boolean

init() public method

}}}
public init ( )

isClicked() public method

public isClicked ( $name )

isLoadedFromDB() public method

public isLoadedFromDB ( )

isSubmitted() public method

public isSubmitted ( )

lateSubmit() public method

public lateSubmit ( )

loadData() public method

public loadData ( )

offsetExists() public method

{{{ ArrayAccess support
public offsetExists ( $name )

offsetGet() public method

public offsetGet ( $name )

offsetSet() public method

public offsetSet ( $name, $val )

offsetUnset() public method

public offsetUnset ( $name )

onSubmit() public method

public onSubmit ( $callback )

render() public method

public render ( )

save() public method

public save ( )

set() public method

* temporarily disabled. TODO: will be implemented with abstract datatype function setSource($table,$db_fields=null){ if(is_null($db_fields)){ $db_fields=array(); foreach($this->elements as $key=>$el){ if(!($el instanceof Form_Field))continue; if($el->no_save)continue; $db_fields[]=$key; } } $this->dq = $this->app->db->dsql() ->table($table) ->field('*',$table) ->limit(1); return $this; }
public set ( $field_or_array, $value = UNDEFINED )

setFieldError() public method

* external error management
public setFieldError ( $field, $name )

setLayout() public method

public setLayout ( $template )

showAjaxError() public method

Should show error in field. Override this method to change form default alert.
public showAjaxError ( object $field, string $msg )
$field object Field instance that caused error
$msg string message to show

submitted() public method

public submitted ( )

update() public method

* obsolete in 4.3 - use save()
public update ( )

validate() public method

public validate ( $rule )

Property Details

$ajax_submits protected_oe property

Contains AJAX instances assigned to buttons.
protected array $ajax_submits
return array

$app public_oe property

public App_Web $app
return App_Web

$bail_out public_oe property

If this is true, we won't load data or submit or validate anything.
public null|bool $bail_out
return null | boolean

$conditions protected_oe property

protected array $conditions
return array

$data public_oe property

Afterwards fields will link to $this->data, so changing $this->data['fld_name'] would actually affect field's value. You should use $this->set() and $this->get() to read/write individual field values. You should use $this->setStaticSource() to load values from hash, BUT - AAAAAAAAAA: this array is no more!!!
public array $data
return array

$default_controller public_oe property

Class name of default controller
public $default_controller

$default_exception public_oe property

Class name of default exception
public $default_exception

$errors public_oe property

Here we will have a list of errors occured in the form, when we tried to submit it. field_name => error
public array $errors
return array

$get_field protected_oe property

If condition was passed to a form through GET, contains a GET field name.
protected null|string $get_field
return null | string

$js_widget public_oe property

JS widget name
public $js_widget

$js_widget_arguments public_oe property

JS widget options
public $js_widget_arguments

$layout public_oe property

Template of layout if form has one.
public View $layout
return View

$loaded_from_db protected_oe property

true - update() will try updating existing row. false - it would insert new.
protected bool $loaded_from_db
return boolean

$owner public_oe property

public View $owner
return View

$search_for_field_spots public_oe property

Normally form fields are inserted using a form template. If you.
public $search_for_field_spots

$template_chunks public_oe property

Those templates will be used when rendering form and fields.
public array $template_chunks
return array

$validator public_oe property

Validator object
public $validator