PHP Class Field_Base, atk4

Inheritance: extends AbstractObject
显示文件 Open project: atk4/atk4

Public Properties

Property Type Description
$actual_field
$allowHTML
$auto_track_element
$caption
$defaultValue
$description
$display ???
$editable
$emptyText
$group
$has_default_value
$hidden
$hint
$listData array | null
$mandatory
$onField Callbacks
$owner Model
$placeholder
$readonly
$searchable
$sortable
$system
$theModel
$type
$visible

Protected Properties

Property Type Description
$table

Public Methods

Method Description
__toString ( ) : string If field is accidentally converted to string, provide some descriptive information.
actual ( string $t = UNDEFINED ) : string | $this In most cases $model['field'] would match "field" inside a database. In some cases, however, you would want to use different database field. This can happen when you join multiple tables and 'field' appears in multiple tables.
allowHTML ( boolean $t = UNDEFINED ) : boolean | $this Configures the behavior of Form to disable tag stripping form user input.
caption ( string $t = UNDEFINED ) : string | $this Sets field caption which will be used by forms, grids and other view elements as a label. The caption will be localized through $app->_().
defaultValue ( boolean $t = UNDEFINED ) : boolean | $this Default Value is used inside forms when you present them without loaded data. This does not change how model works, which will simply avoid including unchanged field into insert/update queries.
display ( mixed $t = UNDEFINED ) : mixed | $this Normally views will attempt to pick most suitable way to present field.
editable ( boolean $t = UNDEFINED ) : boolean | $this Set editable to false, if you want to exclude field from forms or other means of editing data. This does not affect the actual model values.
emptyText ( string $t = UNDEFINED ) : string | $this What to display when nothing is selected or entered? This will be displayed on a drop-down when no value is selected: ("Choose .
enum ( array $t ) : array Similar to listData() but accepts array of values instead of hash:.
get ( ) : mixed Get the value of the field of a loaded model. If model is not loaded will return default value instead.
getBooleanValue ( mixed $value ) : integer | null Converts true/false into boolean representation according to the "enum"
getModel ( ) : string Returns current model. This is different than other setters getters, but it's done to keep consistency with the rest of Agile Toolkit.
group ( string $t = UNDEFINED ) : string | $this While you may use visible(), editable() to include or exclude fields from appearing in certain scenarios, you can also define a group which you then can display instead of listing all fields manually inside setModel(). Read more about Actual Fields.
hidden ( boolean $t = UNDEFINED ) : boolean | $this Hide field. Not sure!
hint ( string $t = UNDEFINED ) : string | $this Sets field hint which will be used by forms.
length ( integer $t = UNDEFINED ) : integer | $this This will provide a HTML settings on a field for maximum field size.
listData ( array $t = UNDEFINED ) : array | $this Supplies a list data for multi-value fields (selects, radio buttons, checkbox area, autocomplete). You may also use enum(). This setting is typically used with a static falues (Male / Female), if your field values could be described through a different model, use setModel() or better yet - hasOne().
mandatory ( boolean $t = UNDEFINED ) : boolean | $this Asterisk will be displayed by the form (if field is include in "actual" fields. This property will not affect the direct use of the field inside model. If you would like that your model complains about empty fields, you should edit beforeSave hook.
onField ( callback $c = UNDEFINED ) : string | $this Pass a callback to onField() which is executed with the argument containing a field view, when model is associated with a form.
placeholder ( string $t = UNDEFINED ) : string | $this Sets field placeholder (gray text inside input when it's empty).
readonly ( boolean $t = UNDEFINED ) : boolean | $this Read only setting will affect the way how field is presented by views.
required ( boolean $t = UNDEFINED ) : boolean | $this
sanitize ( mixed $value ) : mixed This is used in Controller_Data_SQL to sanitize the value forwarded to dsql.
searchable ( boolean $t = UNDEFINED ) : boolean | $this Setting searchable(true) will instruct Filter and similar views that it should be possible to perform search by this field.
set ( mixed $value = null ) : Field Sets the value of the field. Identical to $model[$fieldname]=$value.
setModel ( string $t = UNDEFINED ) : string | $this Will execute setModel() on a field. Some fields will change their behaviour with this. The value is a string (either Model_Book or Book) but you might be able to use object also.
setValueList ( array $t ) : array Same as listData().
setterGetter ( string $type, mixed $value = UNDEFINED ) : mixed | $this Implementation of generic setter-getter method which supports "UNDEFINED" constant. This method is used by all other sette-getters.
sortable ( boolean $t = UNDEFINED ) : boolean | $this Will instruct Grid and similar views that the sorting controls must be enabled for this field.
system ( boolean $t = UNDEFINED ) : boolean | $this Marking field as system will cause it to always be loaded, even if it's not requested through Actual Fields. It will also hide the field making it dissapear from Grids and Forms. A good examples of system fields are "id" or "created_dts".
table ( string $t = UNDEFINED ) : string | $this If is set, it contains the correct table that stores this field.
type ( string $t = UNDEFINED ) : string | $this Logical type of model field. This universal type is recognized by view controllers (such as Controller_MVCForm, Controller_MVCGrid to convert into supported field types.
visible ( boolean $t = UNDEFINED ) : boolean | $this Controls field appearance in Grid or similar views.

Method Details

__toString() public method

If field is accidentally converted to string, provide some descriptive information.
public __toString ( ) : string
return string descriptive

actual() public method

You can specify actual field when you declare a field within a model: $model->addField('modelfield','dbfield'); If you are unable to use addField (such as using custom field class), you can use actual() modifier: $model->add('filestore/File','modelfield')->actual('dbfield'); Another potential use is if your database structure does not match model convention: $model->hasOne('Book')->actual('IDBOOK');
public actual ( string $t = UNDEFINED ) : string | $this
$t string new value
return string | $this current value if $t=UNDEFINED

allowHTML() public method

By default all tags are stripped, setting this property to true will no longer strip tags.
public allowHTML ( boolean $t = UNDEFINED ) : boolean | $this
$t boolean new value
return boolean | $this current value if $t=UNDEFINED

caption() public method

Sets field caption which will be used by forms, grids and other view elements as a label. The caption will be localized through $app->_().
public caption ( string $t = UNDEFINED ) : string | $this
$t string new value
return string | $this current value if $t=UNDEFINED

defaultValue() public method

Default Value is used inside forms when you present them without loaded data. This does not change how model works, which will simply avoid including unchanged field into insert/update queries.
public defaultValue ( boolean $t = UNDEFINED ) : boolean | $this
$t boolean new value
return boolean | $this current value if $t=UNDEFINED

display() public method

For example, type='date' will be presented with DatePicker field in form. You might be using add-ons or might have created your own field class. If you would like to use it to present the field, use display(). If you specify string it will be used by all views, otherwise specify it as associtive array:. $field->display(array('form'=>'line','grid'=>'button'));
public display ( mixed $t = UNDEFINED ) : mixed | $this
$t mixed new value
return mixed | $this current value if $t=UNDEFINED

editable() public method

Set editable to false, if you want to exclude field from forms or other means of editing data. This does not affect the actual model values.
public editable ( boolean $t = UNDEFINED ) : boolean | $this
$t boolean new value
return boolean | $this current value if $t=UNDEFINED

emptyText() public method

.") if you are using this setting with a text field it will set a placeholder HTML property.
public emptyText ( string $t = UNDEFINED ) : string | $this
$t string new value
return string | $this current value if $t=UNDEFINED

enum() public method

listData(array(1=>'Male', 2=>'Female')); enum(array('male','female')); The value will be stored in database and also displayed to user.
public enum ( array $t ) : array
$t array Array( id => val )
return array current value if $t=UNDEFINED

get() public method

Get the value of the field of a loaded model. If model is not loaded will return default value instead.
public get ( ) : mixed
return mixed current value of a field

getBooleanValue() public method

Converts true/false into boolean representation according to the "enum"
public getBooleanValue ( mixed $value ) : integer | null
$value mixed
return integer | null

getModel() public method

Returns current model. This is different than other setters getters, but it's done to keep consistency with the rest of Agile Toolkit.
public getModel ( ) : string
return string current associated model Class

group() public method

While you may use visible(), editable() to include or exclude fields from appearing in certain scenarios, you can also define a group which you then can display instead of listing all fields manually inside setModel(). Read more about Actual Fields.
public group ( string $t = UNDEFINED ) : string | $this
$t string new value
return string | $this current value if $t=UNDEFINED

hidden() public method

Hide field. Not sure!
public hidden ( boolean $t = UNDEFINED ) : boolean | $this
$t boolean new value
return boolean | $this current value if $t=UNDEFINED

hint() public method

Sets field hint which will be used by forms.
public hint ( string $t = UNDEFINED ) : string | $this
$t string new value
return string | $this current value if $t=UNDEFINED

length() public method

The length of a field will not be enforced by this setting.
public length ( integer $t = UNDEFINED ) : integer | $this
$t integer new value
return integer | $this current value if $t=UNDEFINED

listData() public method

Supplies a list data for multi-value fields (selects, radio buttons, checkbox area, autocomplete). You may also use enum(). This setting is typically used with a static falues (Male / Female), if your field values could be described through a different model, use setModel() or better yet - hasOne().
public listData ( array $t = UNDEFINED ) : array | $this
$t array Array( id => val )
return array | $this current value if $t=UNDEFINED

mandatory() public method

Asterisk will be displayed by the form (if field is include in "actual" fields. This property will not affect the direct use of the field inside model. If you would like that your model complains about empty fields, you should edit beforeSave hook.
public mandatory ( boolean $t = UNDEFINED ) : boolean | $this
$t boolean new value
return boolean | $this current value if $t=UNDEFINED

onField() public method

Pass a callback to onField() which is executed with the argument containing a field view, when model is associated with a form.
public onField ( callback $c = UNDEFINED ) : string | $this
$c callback new value
return string | $this current value if $t=UNDEFINED

placeholder() public method

Sets field placeholder (gray text inside input when it's empty).
public placeholder ( string $t = UNDEFINED ) : string | $this
$t string new value
return string | $this current value if $t=UNDEFINED

readonly() public method

While model field is still writable directly, the Form will not try to change the value of this field.
public readonly ( boolean $t = UNDEFINED ) : boolean | $this
$t boolean new value
return boolean | $this current value if $t=UNDEFINED

required() public method

Deprecation: 4.3.0 use mandatory() instead
public required ( boolean $t = UNDEFINED ) : boolean | $this
$t boolean new value
return boolean | $this current value if $t=UNDEFINED

sanitize() public method

This is used in Controller_Data_SQL to sanitize the value forwarded to dsql.
public sanitize ( mixed $value ) : mixed
$value mixed
return mixed

searchable() public method

Setting searchable(true) will instruct Filter and similar views that it should be possible to perform search by this field.
public searchable ( boolean $t = UNDEFINED ) : boolean | $this
$t boolean new value
return boolean | $this current value if $t=UNDEFINED

set() public method

Sets the value of the field. Identical to $model[$fieldname]=$value.
public set ( mixed $value = null ) : Field
$value mixed new value
return Field $this

setModel() public method

I suggest to use $model->hasOne($model) instead of setModel($model)
public setModel ( string $t = UNDEFINED ) : string | $this
$t string new value
return string | $this current value if $t=UNDEFINED

setValueList() public method

Same as listData().
public setValueList ( array $t ) : array
$t array Array( id => val )
return array current value if $t=UNDEFINED

setterGetter() public method

Implementation of generic setter-getter method which supports "UNDEFINED" constant. This method is used by all other sette-getters.
public setterGetter ( string $type, mixed $value = UNDEFINED ) : mixed | $this
$type string Corresponds to the name of property of a field
$value mixed New value for a property.
return mixed | $this new or current pperty (if value is UNDEFINED)

sortable() public method

Will instruct Grid and similar views that the sorting controls must be enabled for this field.
public sortable ( boolean $t = UNDEFINED ) : boolean | $this
$t boolean new value
return boolean | $this current value if $t=UNDEFINED

system() public method

Marking field as system will cause it to always be loaded, even if it's not requested through Actual Fields. It will also hide the field making it dissapear from Grids and Forms. A good examples of system fields are "id" or "created_dts".
public system ( boolean $t = UNDEFINED ) : boolean | $this
$t boolean new value
return boolean | $this current value if $t=UNDEFINED

table() public method

Used in join environment.
public table ( string $t = UNDEFINED ) : string | $this
$t string
return string | $this

type() public method

Logical type of model field. This universal type is recognized by view controllers (such as Controller_MVCForm, Controller_MVCGrid to convert into supported field types.
public type ( string $t = UNDEFINED ) : string | $this
$t string new value
return string | $this current value if $t=UNDEFINED

visible() public method

Controls field appearance in Grid or similar views.
public visible ( boolean $t = UNDEFINED ) : boolean | $this
$t boolean new value
return boolean | $this current value if $t=UNDEFINED

Property Details

$actual_field public_oe property

public $actual_field

$allowHTML public_oe property

public $allowHTML

$auto_track_element public_oe property

public $auto_track_element

$caption public_oe property

public $caption

$defaultValue public_oe property

public $defaultValue

$description public_oe property

public $description

$display public_oe property

???
public $display

$editable public_oe property

public $editable

$emptyText public_oe property

public $emptyText

$group public_oe property

public $group

$has_default_value public_oe property

public $has_default_value

$hidden public_oe property

public $hidden

$hint public_oe property

public $hint

$listData public_oe property

public array|null $listData
return array | null

$mandatory public_oe property

public $mandatory

$onField public_oe property

Callbacks
public $onField

$owner public_oe property

public Model $owner
return Model

$placeholder public_oe property

public $placeholder

$readonly public_oe property

public $readonly

$searchable public_oe property

public $searchable

$sortable public_oe property

public $sortable

$system public_oe property

public $system

$table protected_oe property

protected $table

$theModel public_oe property

public $theModel

$type public_oe property

public $type

$visible public_oe property

public $visible