\Charcoal\Admin\Widget\FormGroupTemplateOptionsFormGroup

Template Options Form Group

The form group widget displays a set of form controls based on properties assigned to a template controller's metadata.

This works best (minimal setup) if your model implements \Charcoal\App\Template\TemplateInterface.

Examples

Example #1 — Template options widget

{
    "title": "Template Options",
    "type": "charcoal/admin/widget/form-group/template-options",
    "template": "charcoal/admin/widget/form-group/structure"
}

Example #2 — With custom template controller

{
    "title": "Template Options",
    "type": "charcoal/admin/widget/form-group/template-options",
    "template": "charcoal/admin/widget/form-group/structure",
    "controller_ident": "foobar/template/front-page"
}

Example #3 — With property for selecting a template controller

When changing the object's active template, the form must be saved and reloaded to display the new template options. {@todo Eventually, the form will automatically reload the template options widget when changing templates}.

{
    "title": "Template Options",
    "type": "charcoal/admin/widget/form-group/template-options",
    "template": "charcoal/admin/widget/form-group/structure",
    "template_property": "template_ident"
}

Summary

Methods
Properties
Constants
type()
setData()
showHeader()
showFooter()
obj()
setFormGroup()
formGroup()
clearFormGroup()
setStorageProperty()
storageProperty()
structProperties()
formProperties()
setDisplay()
display()
displays()
setShowEmpty()
showEmpty()
__construct()
setDependencies()
setWidgetId()
widgetId()
setGroupProperties()
groupProperties()
setPropertiesOptions()
propertiesOptions()
hasFormProperties()
languages()
description()
notes()
setShowNotes()
showNotesAbove()
template()
setControllerIdent()
controllerIdent()
setTemplateProperty()
templateProperty()
No public properties found
No constants found
finalizeStructure()
parsedFormProperties()
supportedDisplayLayouts()
defaultDisplay()
setMetadataLoader()
metadataLoader()
loadMetadata()
createMetadata()
$obj
$storage
$storageProperty
$isStructureFinalized
$rawData
$display
$showEmpty
$parsedFormProperties
N/A
No private methods found
$formGroup
$widgetId
$showNotesAbove
$groupProperties
$propertiesOptions
$templateProperty
$controllerIdent
$metadataLoader
N/A

Properties

$obj

$obj : \Charcoal\Admin\Widget\FormGroup\ModelInterface|null

The form group's storage model.

Type

\Charcoal\Admin\Widget\FormGroup\ModelInterface|null

$storage

$storage : array|\Charcoal\Property\PropertyInterface|\Charcoal\Admin\Widget\FormGroup\SourceInterface|null

The form group's storage medium.

Type

array|\Charcoal\Property\PropertyInterface|\Charcoal\Admin\Widget\FormGroup\SourceInterface|null

$storageProperty

$storageProperty : \Charcoal\Property\PropertyInterface|null

The form group's storage target. {@deprecated In favor of $storage.}

Type

\Charcoal\Property\PropertyInterface|null

$isStructureFinalized

$isStructureFinalized : boolean

Whether the form is ready.

Type

boolean

$rawData

$rawData : array|null

The form group's raw data.

Type

array|null

$display

$display : string|null

How to display the structure properties.

Type

string|null

$showEmpty

$showEmpty : boolean

How to display an empty structure.

Type

boolean

$parsedFormProperties

$parsedFormProperties : array|null

Type

array|null

$formGroup

$formGroup : \Charcoal\Ui\FormGroup\FormGroupInterface|null

The form group the input belongs to.

Type

\Charcoal\Ui\FormGroup\FormGroupInterface|null

$widgetId

$widgetId : string

The widget identifier.

Type

string

$showNotesAbove

$showNotesAbove : boolean

Whether notes shoudl be display before or after the form fields.

Type

boolean

$groupProperties

$groupProperties : array

Type

array

$propertiesOptions

$propertiesOptions : array

Type

array

$templateProperty

$templateProperty : \Charcoal\Property\PropertyInterface|null

The form object's property for template controller choices.

Type

\Charcoal\Property\PropertyInterface|null

$controllerIdent

$controllerIdent : \Charcoal\Cms\TemplateableInterface|string|null

The object's template controller identifier.

Type

\Charcoal\Cms\TemplateableInterface|string|null

$metadataLoader

$metadataLoader : \Charcoal\Model\Service\MetadataLoader

Store the metadata loader instance.

Type

\Charcoal\Model\Service\MetadataLoader

Methods

type()

type() : string

Returns

string

showHeader()

showHeader() : boolean

Determine if the header is to be displayed.

Returns

boolean —

If TRUE or unset, check if there is a title.

showFooter()

showFooter() : boolean

Determine if the footer is to be displayed.

Returns

boolean —

If TRUE or unset, check if there are notes.

obj()

obj() : \Charcoal\Model\ModelInterface

Retrieve the form's object.

Throws

\RuntimeException

If the form doesn't have a model.

Returns

\Charcoal\Model\ModelInterface

setFormGroup()

setFormGroup(\Charcoal\Ui\FormGroup\FormGroupInterface  $formGroup) : \Charcoal\Admin\Widget\FormGroup\StructureFormGroup

Set the form input's parent group.

Parameters

\Charcoal\Ui\FormGroup\FormGroupInterface $formGroup

The parent form group object.

Returns

\Charcoal\Admin\Widget\FormGroup\StructureFormGroup

formGroup()

formGroup() : \Charcoal\Ui\FormGroup\FormGroupInterface|null

Retrieve the input's parent group.

Returns

\Charcoal\Ui\FormGroup\FormGroupInterface|null

setStorageProperty()

setStorageProperty(string|\Charcoal\Property\PropertyInterface  $propertyIdent) : \Charcoal\Admin\Widget\FormGroup\StructureFormGroup

Set the form group's storage target.

Must be a property of the form's object model that will receive an associative array of the form group's data.

Parameters

string|\Charcoal\Property\PropertyInterface $propertyIdent

The property identifier—or instance—of a storage property.

Throws

\InvalidArgumentException

If the property identifier is not a string.

\UnexpectedValueException

If a property data is invalid.

Returns

\Charcoal\Admin\Widget\FormGroup\StructureFormGroup

storageProperty()

storageProperty() : \Charcoal\Property\PropertyInterface

Retrieve the form group's storage property master.

Throws

\RuntimeException

If the storage property was not previously set.

Returns

\Charcoal\Property\PropertyInterface

structProperties()

structProperties() : array

Retrieve the properties from the storage property's structure.

Returns

array

formProperties()

formProperties() : mixed|\Charcoal\Admin\Widget\Generator

Retrieve the object's properties from the form.

Returns

mixed|\Charcoal\Admin\Widget\Generator

setDisplay()

setDisplay(string  $display) : self

Set the property's display layout.

Parameters

string $display

The layout for the tickable elements.

Throws

\InvalidArgumentException

If the given layout is invalid.

\OutOfBoundsException

If the given layout is unsupported.

Returns

self

display()

display() : string|null

Retrieve the property's display layout.

Returns

string|null

displays()

displays() : array

Retrieve the display layouts; for templating.

Returns

array

setShowEmpty()

setShowEmpty(boolean  $show) : self

Show/hide the notice when the structure is empty.

Parameters

boolean $show

Show (TRUE) or hide (FALSE) the notice.

Returns

self

showEmpty()

showEmpty() : boolean

Determine if a notice should be displayed when the structure is empty.

Returns

boolean

__construct()

__construct(array|\ArrayAccess  $data) 

Parameters

array|\ArrayAccess $data

Dependencies.

setDependencies()

setDependencies(\Pimple\Container  $container) : void

Inject dependencies from a DI Container.

Parameters

\Pimple\Container $container

A dependencies container instance.

setWidgetId()

setWidgetId(string  $widgetId) : \Charcoal\Admin\Widget\AdminWidget

Parameters

string $widgetId

The widget identifier.

Returns

\Charcoal\Admin\Widget\AdminWidget —

Chainable

widgetId()

widgetId() : string

Returns

string

setGroupProperties()

setGroupProperties(array  $properties) : \Charcoal\Admin\Widget\FormGroupWidget

Parameters

array $properties

The group properties.

Returns

\Charcoal\Admin\Widget\FormGroupWidget

Chainable

groupProperties()

groupProperties() : array

Returns

array

setPropertiesOptions()

setPropertiesOptions(array  $properties) : \Charcoal\Admin\Widget\FormGroupWidget

Parameters

array $properties

The options to customize the group properties.

Returns

\Charcoal\Admin\Widget\FormGroupWidget

Chainable

propertiesOptions()

propertiesOptions() : array

Returns

array

hasFormProperties()

hasFormProperties() : boolean

Determine if the form group has properties.

Returns

boolean

languages()

languages() : array

Retrieve the available languages, formatted for the sidebar language-switcher.

Returns

array

description()

description() : \Charcoal\Admin\Widget\Translation|string|null

Returns

\Charcoal\Admin\Widget\Translation|string|null

notes()

notes() : \Charcoal\Admin\Widget\Translation|string|null

Returns

\Charcoal\Admin\Widget\Translation|string|null

setShowNotes()

setShowNotes(boolean|string  $show) : \Charcoal\Admin\Widget\FormGroupWidget

Show/hide the widget's notes.

Parameters

boolean|string $show

Whether to show or hide notes.

Returns

\Charcoal\Admin\Widget\FormGroupWidget

Chainable

showNotesAbove()

showNotesAbove() : boolean

Returns

boolean

template()

template() : string

Returns

string

setControllerIdent()

setControllerIdent(mixed  $ident) : \Charcoal\Cms\TemplateableInterface

Set the form object's template controller identifier.

Parameters

mixed $ident

The template controller identifier.

Returns

\Charcoal\Cms\TemplateableInterface —

Chainable

controllerIdent()

controllerIdent() : mixed

Retrieve the form object's template controller identifier.

Returns

mixed

setTemplateProperty()

setTemplateProperty(string|\Charcoal\Property\PropertyInterface  $propertyIdent) : \Charcoal\Admin\Widget\FormGroup\StructureFormGroup

Set the form object's property for template controller choices.

Must be a property of the form's object model that will supply a list of properties.

Parameters

string|\Charcoal\Property\PropertyInterface $propertyIdent

The property identifier—or instance—of a storage property.

Throws

\InvalidArgumentException

If the property identifier is not a string.

\UnexpectedValueException

If a property data is invalid.

Returns

\Charcoal\Admin\Widget\FormGroup\StructureFormGroup

templateProperty()

templateProperty() : \Charcoal\Property\PropertyInterface|null

Retrieve form object's property for template controller choices.

Throws

\RuntimeException

If the template property was not previously set.

Returns

\Charcoal\Property\PropertyInterface|null

finalizeStructure()

finalizeStructure(boolean  $reload = false) : void

Finalize the form group's properies, entries, and layout.

Parameters

boolean $reload

Rebuild the form group's structure.

parsedFormProperties()

parsedFormProperties() : array

Parse the form group and model properties.

Returns

array

supportedDisplayLayouts()

supportedDisplayLayouts() : array

Retrieve the supported display layouts.

Returns

array

defaultDisplay()

defaultDisplay() : array

Retrieve the default display layout.

Returns

array

setMetadataLoader()

setMetadataLoader(\Charcoal\Model\Service\MetadataLoader  $loader) : self

Set a metadata loader.

Parameters

\Charcoal\Model\Service\MetadataLoader $loader

The loader instance, used to load metadata.

Returns

self

metadataLoader()

metadataLoader() : \Charcoal\Model\Service\MetadataLoader

Retrieve the metadata loader.

Throws

\RuntimeException

If the metadata loader was not previously set.

Returns

\Charcoal\Model\Service\MetadataLoader

loadMetadata()

loadMetadata(string  $metadataIdent) : \Charcoal\Model\MetadataInterface

Load a metadata file.

Parameters

string $metadataIdent

A metadata file path or namespace.

Returns

\Charcoal\Model\MetadataInterface

createMetadata()

createMetadata() : \Charcoal\Model\MetadataInterface

Returns

\Charcoal\Model\MetadataInterface