PHP Class Former\Traits\Field

Inheritance: extends Former\Traits\FormerObject, implements Former\Interfaces\FieldInterface
Show file Open project: anahkiasen/former Class Usage Examples

Protected Properties

Property Type Description
$app Illuminate\Container\Container The IoC Container
$bind string The field's bind destination
$element string The field's default element
$form Former\Former\Form The Form instance
$group Former\Form\Group The field's group
$isSelfClosing boolean Whether the Field is self-closing or not
$label string A label for the field (if not using Bootstrap)

Public Methods

Method Description
__call ( string $method, $parameters ) Redirect calls to the group if necessary
__construct ( Illuminate\Container\Container $app, string $type, $name, $label, $value, $attributes ) Set up a Field instance
__toString ( ) : string Prints out the field
bind ( $destination ) Change the field's bind destination
forceValue ( string $value ) Set the Field value no matter what
getLabel ( ) : string Get the field's labels
getRules ( ) : array Get the rules applied to the current field
isButton ( ) : boolean Check if the field is a button
isCheckable ( ) : boolean Check if field is a checkbox or a radio
isRequired ( ) : boolean Whether the current field is required or not
isUnwrappable ( ) : boolean Check if a field is unwrappable (no label)
label ( string $text, array $attributes = [] ) : Field Adds a label to the group/field
name ( string $name ) Change the field's name
rule ( string $rule ) Apply a Live Validation rule by chaining
rules ( $rules ) Apply multiple rules passed as a string.
value ( string $value ) Classic setting of attribute, won't overwrite any populate() attempt
wrapAndRender ( ) : string Prints out the field, wrapped in its group

Protected Methods

Method Description
currentFramework ( ) : Former\Traits\Framework Get the current framework instance

Private Methods

Method Description
automaticLabels ( string $name, string $label ) : false | null Ponders a label and a field name, and tries to get the best out of it
repopulate ( $fallback = null ) Use values stored in Former to populate the current field

Method Details

__call() public method

Redirect calls to the group if necessary
public __call ( string $method, $parameters )
$method string

__construct() public method

Set up a Field instance
public __construct ( Illuminate\Container\Container $app, string $type, $name, $label, $value, $attributes )
$app Illuminate\Container\Container
$type string A field type

__toString() public method

Prints out the field
public __toString ( ) : string
return string

bind() public method

Change the field's bind destination
public bind ( $destination )
$destination

currentFramework() protected method

Get the current framework instance
protected currentFramework ( ) : Former\Traits\Framework
return Former\Traits\Framework

forceValue() public method

Set the Field value no matter what
public forceValue ( string $value )
$value string A new value

getLabel() public method

Get the field's labels
public getLabel ( ) : string
return string

getRules() public method

Get the rules applied to the current field
public getRules ( ) : array
return array An array of rules

isButton() public method

Check if the field is a button
public isButton ( ) : boolean
return boolean

isCheckable() public method

Check if field is a checkbox or a radio
public isCheckable ( ) : boolean
return boolean

isRequired() public method

Whether the current field is required or not
public isRequired ( ) : boolean
return boolean

isUnwrappable() public method

Check if a field is unwrappable (no label)
public isUnwrappable ( ) : boolean
return boolean

label() public method

Adds a label to the group/field
public label ( string $text, array $attributes = [] ) : Field
$text string A label
$attributes array The label's attributes
return Field A field

name() public method

Change the field's name
public name ( string $name )
$name string The new name

rule() public method

Apply a Live Validation rule by chaining
public rule ( string $rule )
$rule string The rule

rules() public method

Apply multiple rules passed as a string.
public rules ( $rules )
$rules

value() public method

Classic setting of attribute, won't overwrite any populate() attempt
public value ( string $value )
$value string A new value

wrapAndRender() public method

Prints out the field, wrapped in its group
public wrapAndRender ( ) : string
return string

Property Details

$app protected property

The IoC Container
protected Container,Illuminate\Container $app
return Illuminate\Container\Container

$bind protected property

The field's bind destination
protected string $bind
return string

$element protected property

The field's default element
protected string $element
return string

$form protected property

The Form instance
protected Form,Former\Former $form
return Former\Former\Form

$group protected property

The field's group
protected Group,Former\Form $group
return Former\Form\Group

$isSelfClosing protected property

Whether the Field is self-closing or not
protected bool $isSelfClosing
return boolean

$label protected property

A label for the field (if not using Bootstrap)
protected string $label
return string