Overview

Namespaces

  • Charcoal
    • Ui
      • Dashboard
      • Form
      • FormGroup
      • FormInput
      • Layout
      • Menu
      • MenuItem
      • ServiceProvider

Classes

  • AbstractForm
  • FormBuilder
  • FormConfig
  • GenericForm

Interfaces

  • FormInterface

Traits

  • FormTrait
  • Overview
  • Namespace
  • Class

Trait FormTrait

Provides an implementation of Charcoal\Ui\Form\FormInterface.

Direct Known Users

Charcoal\Ui\Form\AbstractForm

Indirect Known Users

Charcoal\Ui\Form\GenericForm
Namespace: Charcoal\Ui\Form
Located at Charcoal/Ui/Form/FormTrait.php
Methods summary
public Charcoal\Ui\Form\FormInterface
# setFormGroupFactory( Charcoal\Factory\FactoryInterface $factory )

Parameters

$factory
A factory, to create customized form gorup objects.

Returns

Charcoal\Ui\Form\FormInterface
Chainable
protected Charcoal\Ui\Form\FormInterface
# formGroupFactory( )

Returns

Charcoal\Ui\Form\FormInterface
Chainable

Throws

Exception
If the form group factory object was not set / injected.
public Charcoal\Ui\Form\FormInterface
# setGroupCallback( callable $cb )

Parameters

$cb
The group callback.

Returns

Charcoal\Ui\Form\FormInterface
Chainable
public Charcoal\Ui\Form\FormInterface
# setAction( string $action )

Parameters

$action
The "action" value, typically a URL.

Returns

Charcoal\Ui\Form\FormInterface
Chainable

Throws

InvalidArgumentException
If the action argument is not a string.
public string
# action( )

Returns

string
public Charcoal\Ui\Form\FormInterface
# setMethod( string $method )

Set the method (forcing lowercase) to "post" or "get".

Set the method (forcing lowercase) to "post" or "get".

Parameters

$method
Either "post" or "get".

Returns

Charcoal\Ui\Form\FormInterface
Chainable

Throws

InvalidArgumentException
If the method is not post or get.
public string
# method( )

Returns

string
Either "post" or "get".
public Charcoal\Ui\Form\FormInterface
# setL10nMode( string $mode )

Parameters

$mode
The l10n mode.

Returns

Charcoal\Ui\Form\FormInterface
Chainable
public string
# l10nMode( )

Returns

string
public Charcoal\Ui\Form\FormInterface
# setGroups( array $groups )

Set the object's form groups.

Set the object's form groups.

Parameters

$groups
A collection of group structures.

Returns

Charcoal\Ui\Form\FormInterface
Chainable
public Charcoal\Ui\Form\FormInterface
# addGroup( string $groupIdent, array|Charcoal\Ui\FormGroup\FormGroupInterface $group )

Add a form group.

Add a form group.

Parameters

$groupIdent
The group identifier.
$group
The group object or structure.

Returns

Charcoal\Ui\Form\FormInterface
Chainable

Throws

InvalidArgumentException
If the identifier is not a string or the group is invalid.
protected Charcoal\Ui\FormGroup\FormGroupInterface
# createFormGroup( array $data = null )

Create a new form group widget.

Create a new form group widget.

Parameters

$data
Optional. The form group data to set.

Returns

Charcoal\Ui\FormGroup\FormGroupInterface
protected Charcoal\Ui\FormGroup\FormGroupInterface
# updateFormGroup( Charcoal\Ui\FormGroup\FormGroupInterface $group, array $groupData = null, string|null $groupIdent = null )

Update the given form group widget.

Update the given form group widget.

Parameters

$group
The form group to update.
$groupData
Optional. The new group data to apply.
$groupIdent
Optional. The new group identifier.

Returns

Charcoal\Ui\FormGroup\FormGroupInterface
public string
# defaultGroupType( )

Retrieve the default form group class name.

Retrieve the default form group class name.

Returns

string
public Charcoal\Ui\FormGroup\FormGroupInterface[]|Generator
# groups( callable $groupCallback = null )

Retrieve the form groups.

Retrieve the form groups.

Parameters

$groupCallback
Optional callback applied to each form group.

Returns

Charcoal\Ui\FormGroup\FormGroupInterface[]|Generator
public boolean
# hasGroups( )

Determine if the form has any groups.

Determine if the form has any groups.

Returns

boolean
public boolean
# hasGroup( string $groupIdent )

Determine if the form has a given group.

Determine if the form has a given group.

Parameters

$groupIdent
The group identifier to look up.

Returns

boolean

Throws

InvalidArgumentException
If the group identifier is invalid.
public integer
# numGroups( )

Count the number of form groups.

Count the number of form groups.

Returns

integer
public ObjectFormWidget
# setGroupDisplayMode( string $mode )

Set the widget's content group display mode.

Set the widget's content group display mode.

Currently only supports "tab".

Parameters

$mode
Group display mode.

Returns

ObjectFormWidget
Chainable.

Throws

InvalidArgumentException
If the display mode is not a string.
public string
# groupDisplayMode( )

Retrieve the widget's content group display mode.

Retrieve the widget's content group display mode.

Returns

string
Group display mode.
public boolean
# isTabbable( )

Determine if content groups are to be displayed as tabbable panes.

Determine if content groups are to be displayed as tabbable panes.

Returns

boolean
public Charcoal\Ui\Form\FormInterface
# setFormData( array $formData )

Parameters

$formData
The (pre-populated) form data, as [$key=>$val] array.

Returns

Charcoal\Ui\Form\FormInterface
Chainable
public Charcoal\Ui\Form\FormInterface
# addFormData( string $key, mixed $val )

Parameters

$key
The form data key, or poperty identifier.
$val
The form data value, for a given key.

Returns

Charcoal\Ui\Form\FormInterface
Chainable

Throws

InvalidArgumentException
If the key argument is not a string.
public array
# formData( )

Returns

array
protected static integer
# sortGroupsByPriority( Charcoal\Ui\FormGroup\FormGroupInterface $a, Charcoal\Ui\FormGroup\FormGroupInterface $b )

Static comparison function used by uasort().

Static comparison function used by uasort().

Parameters

$a
Form Group A.
$b
Form Group B.

Returns

integer
Sorting value: -1 or 1
Properties summary
protected string $groupDisplayMode

The form's display mode for groups.

The form's display mode for groups.

#
protected Charcoal\Ui\FormGroup\FormGroupInterface[] $groups

The form's field groups.

The form's field groups.

# []
protected Charcoal\Factory\FactoryInterface $formGroupFactory

Store the form's group factory instance.

Store the form's group factory instance.

#
API documentation generated by ApiGen