\Charcoal\Admin\WidgetObjectFormWidget

Object Admin Form

For submitting information to a web server.

The widget is a variant of \Charcoal\Ui\Form\AbstractForm.

Summary

Methods
Properties
Constants
setObjType()
objType()
setObjId()
objId()
objIdWithSlashes()
setObjBaseClass()
objBaseClass()
proto()
hasObj()
obj()
setDependencies()
httpRequest()
createFormProperty()
setSidebars()
addSidebar()
sidebars()
setFormProperties()
addFormProperties()
addFormProperty()
formProperties()
setHiddenProperties()
addHiddenProperties()
addHiddenProperty()
hiddenProperties()
submitLabel()
defaultSubmitLabel()
defaultGroupType()
setTemplate()
template()
setWidgetId()
widgetId()
setType()
type()
setIdent()
ident()
setDataSources()
dataSources()
dataSourceFilter()
setLabel()
label()
actions()
setShowActions()
showActions()
setShowLabel()
showLabel()
adminUrl()
setBaseUrl()
baseUrl()
setPriority()
priority()
widgetType()
setData()
setFormIdent()
formIdentFallback()
formIdent()
setNextUrl()
action()
formProperty()
setFormData()
formData()
objData()
$widgetId
DATA_SOURCE_REQUEST
DATA_SOURCE_OBJECT
setModelFactory()
modelFactory()
createOrLoadObj()
cloneObj()
createObjFromBluePrint()
createObj()
loadObj()
validateObjType()
validateObjBaseClass()
setHttpRequest()
setWidgetFactory()
widgetFactory()
dataFromRequest()
acceptedRequestData()
sortSidebarsByPriority()
addDataSources()
acceptedDataSources()
defaultDataSources()
defaultDataSourceFilters()
resolveDataSourceFilter()
mergeDataSources()
dataFromObject()
createFormGroup()
updateFormGroup()
$objType
$objId
$objBaseClass
$obj
$sidebars
$formProperties
$hiddenProperties
$submitLabel
$baseUrl
$adminConfig
$formIdent
$formData
N/A
No private methods found
$modelFactory
$httpRequest
$widgetFactory
$type
$template
$ident
$label
$lang
$showLabel
$showActions
$priority
$dataSources
$dataSourceFilters
N/A

Constants

DATA_SOURCE_REQUEST

DATA_SOURCE_REQUEST

DATA_SOURCE_OBJECT

DATA_SOURCE_OBJECT

Properties

$widgetId

$widgetId : string

Type

string

$objType

$objType : string|null

Type

string|null

$objId

$objId : string|\Charcoal\Admin\Ui\numeric|null

Type

string|\Charcoal\Admin\Ui\numeric|null

$objBaseClass

$objBaseClass : string

Type

string

$obj

$obj : \Charcoal\Model\ModelInterface

Type

\Charcoal\Model\ModelInterface

$sidebars

$sidebars : array

The form's sidebars.

Type

array

$formProperties

$formProperties : array

The form's controls.

Type

array

$hiddenProperties

$hiddenProperties : array

The form's hidden controls.

Type

array

$submitLabel

$submitLabel : \Charcoal\Admin\Widget\Translation|string

Label for the form submission button.

Type

\Charcoal\Admin\Widget\Translation|string

$baseUrl

$baseUrl : \Psr\Http\Message\UriInterface|string

The base URI.

Type

\Psr\Http\Message\UriInterface|string

$adminConfig

$adminConfig : \Charcoal\Admin\Config

Store a reference to the admin configuration.

Type

\Charcoal\Admin\Config

$formIdent

$formIdent : string

Type

string

$formData

$formData : array

Type

array

$modelFactory

$modelFactory : \Charcoal\Factory\FactoryInterface

Type

\Charcoal\Factory\FactoryInterface

$httpRequest

$httpRequest : \Psr\Http\Message\RequestInterface

Store the HTTP request object.

Type

\Psr\Http\Message\RequestInterface

$widgetFactory

$widgetFactory : \Charcoal\Factory\FactoryInterface

Store the factory instance for the current class.

Type

\Charcoal\Factory\FactoryInterface

$type

$type : string

Type

string

$template

$template : string

Type

string

$ident

$ident : string

Type

string

$label

$label : \Charcoal\Translator\Translation|string|null

Type

\Charcoal\Translator\Translation|string|null

$lang

$lang : string

Type

string

$showLabel

$showLabel : boolean

Type

boolean

$showActions

$showActions : boolean

Type

boolean

$priority

$priority : integer

Type

integer

$dataSources

$dataSources : array

Extra data sources to merge when setting data on an entity.

Type

array

$dataSourceFilters

$dataSourceFilters : array

Associative array of source identifiers and options to apply when merging.

Type

array

Methods

setObjType()

setObjType(string  $objType) : \Charcoal\Admin\Ui\ObjectContainerInterface

Set the object type.

Parameters

string $objType

The object type.

Throws

\InvalidArgumentException

If provided argument is not of type 'string'.

Returns

\Charcoal\Admin\Ui\ObjectContainerInterface

Chainable

objType()

objType() : string|null

Retrieve the object type.

Returns

string|null

setObjId()

setObjId(string|\Charcoal\Admin\Ui\numeric  $objId) : \Charcoal\Admin\Ui\ObjectContainerInterface

Set the object ID.

Parameters

string|\Charcoal\Admin\Ui\numeric $objId

The object ID to load.

Throws

\InvalidArgumentException

If provided argument is not of type 'scalar'.

Returns

\Charcoal\Admin\Ui\ObjectContainerInterface

Chainable

objId()

objId() : string|\Charcoal\Admin\Ui\numeric|null

Retrieve the object ID.

Returns

string|\Charcoal\Admin\Ui\numeric|null

objIdWithSlashes()

objIdWithSlashes() : string

Retrieve the object ID and addslashes.

Used in template/charcoal/admin/template/form/js.mustache to prevent problems with ID with single or double quotes.

Returns

string —

Escaped ID.

setObjBaseClass()

setObjBaseClass(string  $objBaseClass) : \Charcoal\Admin\Ui\ObjectContainerInterface

Parameters

string $objBaseClass

The base class.

Throws

\InvalidArgumentException

If provided argument is not of type 'string'.

Returns

\Charcoal\Admin\Ui\ObjectContainerInterface

Chainable

objBaseClass()

objBaseClass() : string|null

Returns

string|null

proto()

proto() : \Charcoal\Model\ModelInterface

Retrieve a singleton of the {self::$objType} for prototyping.

Throws

\RuntimeException

If the class has no object type.

Returns

\Charcoal\Model\ModelInterface

hasObj()

hasObj() : boolean

Determine if the class has a concrete object.

Returns

boolean

obj()

obj() : \Charcoal\Model\ModelInterface

Retrieve the object.

Returns

\Charcoal\Model\ModelInterface

setDependencies()

setDependencies(\Pimple\Container  $container) : void

Parameters

\Pimple\Container $container

The DI container.

httpRequest()

httpRequest() : \Psr\Http\Message\RequestInterface

Retrieve the HTTP request object.

Throws

\RuntimeException

If an HTTP request was not previously set.

Returns

\Psr\Http\Message\RequestInterface

createFormProperty()

createFormProperty(array  $data = null) : \Charcoal\Admin\Widget\FormPropertyWidget

Parameters

array $data

Optional. The form property data to set.

Returns

\Charcoal\Admin\Widget\FormPropertyWidget

setSidebars()

setSidebars(array  $sidebars) : \Charcoal\Admin\Widget\FormWidget

Parameters

array $sidebars

The form sidebars.

Returns

\Charcoal\Admin\Widget\FormWidget

Chainable

addSidebar()

addSidebar(string  $sidebarIdent, array|\Charcoal\Admin\Ui\FormSidebarInterface  $sidebar) : \Charcoal\Admin\Widget\FormWidget

Parameters

string $sidebarIdent

The sidebar identifier.

array|\Charcoal\Admin\Ui\FormSidebarInterface $sidebar

The sidebar data or object.

Throws

\InvalidArgumentException

If the ident is not a string or the sidebar is not valid.

Returns

\Charcoal\Admin\Widget\FormWidget

Chainable

sidebars()

sidebars() : array<mixed,\Charcoal\Admin\Ui\FormSidebarInterface>|\Charcoal\Admin\Widget\Generator

Returns

array<mixed,\Charcoal\Admin\Ui\FormSidebarInterface>|\Charcoal\Admin\Widget\Generator

setFormProperties()

setFormProperties(array  $properties) : \Charcoal\Ui\Form\FormInterface

Replace property controls to the form.

Parameters

array $properties

The form properties.

Returns

\Charcoal\Ui\Form\FormInterface —

Chainable

addFormProperties()

addFormProperties(array  $properties) : \Charcoal\Ui\Form\FormInterface

Add property controls to the form.

Parameters

array $properties

The form properties.

Returns

\Charcoal\Ui\Form\FormInterface —

Chainable

addFormProperty()

addFormProperty(string  $propertyIdent, array|\Charcoal\Admin\Widget\FormPropertyInterface  $formProperty) : \Charcoal\Ui\Form\FormInterface

Add a property control to the form.

If a given property uses a hidden form control, the form property will be added to \FormWidget::$hiddenProperties.

Parameters

string $propertyIdent

The property identifier.

array|\Charcoal\Admin\Widget\FormPropertyInterface $formProperty

The property object or structure.

Throws

\InvalidArgumentException

If the identifier or the property is invalid.

Returns

\Charcoal\Ui\Form\FormInterface —

Chainable

formProperties()

formProperties(array  $group = null) : array<mixed,\Charcoal\Admin\Widget\FormPropertyWidget>|\Charcoal\Admin\Widget\Generator

Retrieve the object's properties as form controls.

Parameters

array $group

An optional group to use.

Throws

\UnexpectedValueException

If a property data is invalid.

Returns

array<mixed,\Charcoal\Admin\Widget\FormPropertyWidget>|\Charcoal\Admin\Widget\Generator

setHiddenProperties()

setHiddenProperties(array  $properties) : \Charcoal\Ui\Form\FormInterface

Replace hidden property controls to the form.

Parameters

array $properties

The hidden form properties.

Returns

\Charcoal\Ui\Form\FormInterface —

Chainable

addHiddenProperties()

addHiddenProperties(array  $properties) : \Charcoal\Ui\Form\FormInterface

Add hidden property controls to the form.

Parameters

array $properties

The hidden form properties.

Returns

\Charcoal\Ui\Form\FormInterface —

Chainable

addHiddenProperty()

addHiddenProperty(string  $propertyIdent, array|\Charcoal\Admin\Widget\FormPropertyInterface  $formProperty) : \Charcoal\Ui\Form\FormInterface

Add a hidden property control to the form.

Parameters

string $propertyIdent

The property identifier.

array|\Charcoal\Admin\Widget\FormPropertyInterface $formProperty

The property object or structure.

Throws

\InvalidArgumentException

If the identifier or the property is invalid.

Returns

\Charcoal\Ui\Form\FormInterface —

Chainable

hiddenProperties()

hiddenProperties() : array<mixed,\Charcoal\Admin\Widget\FormPropertyWidget>|\Charcoal\Admin\Widget\Generator

Yield the form's hidden property controls.

Returns

array<mixed,\Charcoal\Admin\Widget\FormPropertyWidget>|\Charcoal\Admin\Widget\Generator

submitLabel()

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

Retrieve the label for the form submission button.

Returns

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

defaultSubmitLabel()

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

Retrieve the default label for the form submission button.

Returns

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

defaultGroupType()

defaultGroupType() : string

Returns

string

setTemplate()

setTemplate(string  $template) : \Charcoal\Admin\UiItemInterface

Parameters

string $template

The UI item's template (identifier).

Throws

\InvalidArgumentException

If the template identifier is not a string.

Returns

\Charcoal\Admin\UiItemInterface —

Chainable

template()

template() : string

Returns

string

setWidgetId()

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

Parameters

string $widgetId

The widget identifier.

Returns

\Charcoal\Admin\AdminWidget

Chainable

widgetId()

widgetId() : string

Returns

string

setType()

setType(string  $type) : \Charcoal\Admin\AdminWidget

Parameters

string $type

The widget type.

Throws

\InvalidArgumentException

If the argument is not a string.

Returns

\Charcoal\Admin\AdminWidget

Chainable

type()

type() : string

Returns

string

setIdent()

setIdent(string  $ident) : \Charcoal\Admin\AdminWidget

Parameters

string $ident

The widget ident.

Throws

\InvalidArgumentException

If the ident is not a string.

Returns

\Charcoal\Admin\AdminWidget

(Chainable)

ident()

ident() : string

Returns

string

setDataSources()

setDataSources(mixed  $sources) : \Charcoal\Admin\AdminWidget

Set extra data sources to merge when setting data on an entity.

Parameters

mixed $sources

One or more data source identifiers to merge data from. Pass NULL to reset the entity back to default sources. Pass FALSE, an empty string or array to disable extra sources.

Returns

\Charcoal\Admin\AdminWidget

Chainable

dataSources()

dataSources() : array<mixed,string>

Retrieve the extra data sources to merge when setting data on an entity.

Returns

array<mixed,string>

dataSourceFilter()

dataSourceFilter(string  $sourceIdent) : callable|null

Retrieve the callable filter for the given data source.

Parameters

string $sourceIdent

A data source identifier.

Throws

\InvalidArgumentException

If the data source is invalid.

Returns

callable|null —

Returns a callable variable.

setLabel()

setLabel(mixed  $label) : \Charcoal\Admin\AdminWidget

Parameters

mixed $label

The label.

Returns

\Charcoal\Admin\AdminWidget

Chainable

label()

label() : \Charcoal\Translator\Translation|string|null

Returns

\Charcoal\Translator\Translation|string|null

actions()

actions() : array

Returns

array

setShowActions()

setShowActions(boolean  $show) : \Charcoal\Admin\AdminWidget

Parameters

boolean $show

The show actions flag.

Returns

\Charcoal\Admin\AdminWidget

Chainable

showActions()

showActions() : boolean

Returns

boolean

setShowLabel()

setShowLabel(boolean  $show) : \Charcoal\Admin\AdminWidget

Parameters

boolean $show

The show label flag.

Returns

\Charcoal\Admin\AdminWidget

Chainable

showLabel()

showLabel() : boolean

Returns

boolean

adminUrl()

adminUrl() : \Psr\Http\Message\UriInterface|string

Retrieve the base URI of the administration area.

Returns

\Psr\Http\Message\UriInterface|string

setBaseUrl()

setBaseUrl(\Psr\Http\Message\UriInterface|string  $uri) : self

Set the base URI of the application.

Parameters

\Psr\Http\Message\UriInterface|string $uri

The base URI.

Returns

self

baseUrl()

baseUrl() : \Psr\Http\Message\UriInterface|string

Retrieve the base URI of the application.

Returns

\Psr\Http\Message\UriInterface|string

setPriority()

setPriority(integer  $priority) : \Charcoal\Admin\AdminWidget

Parameters

integer $priority

The widget's sorting priority.

Returns

\Charcoal\Admin\AdminWidget

Chainable

priority()

priority() : integer

Returns

integer

widgetType()

widgetType() : string

Returns

string

setData()

setData(array  $data) : \Charcoal\Admin\Widget\ObjectForm

Parameters

array $data

The widget data.

Returns

\Charcoal\Admin\Widget\ObjectForm —

Chainable

setFormIdent()

setFormIdent(string  $formIdent) : \Charcoal\Admin\Widget\ObjectForm

Set the key for the form structure to use.

Parameters

string $formIdent

The form identifier.

Throws

\InvalidArgumentException

If the identifier is not a string.

Returns

\Charcoal\Admin\Widget\ObjectForm —

Chainable

formIdentFallback()

formIdentFallback() : string

Retrieve a key for the form structure to use.

If the form key is undefined, resolve a fallback.

Returns

string

formIdent()

formIdent() : string

Retrieve the key for the form structure to use.

Returns

string

setNextUrl()

setNextUrl(string  $url) : \Charcoal\Admin\Widget\ActionInterface

Parameters

string $url

The next URL.

Throws

\InvalidArgumentException

If argument is not a string.

Returns

\Charcoal\Admin\Widget\ActionInterface —

Chainable

action()

action() : string

Form action (target URL)

Returns

string —

Relative URL

formProperty()

formProperty(string  $propertyIdent) : \Charcoal\Admin\Widget\FormPropertyWidget

Retrieve an object property as a form control.

Parameters

string $propertyIdent

An optional group to use.

Throws

\InvalidArgumentException

If the property identifier is not a string.

\UnexpectedValueException

If a property data is invalid.

Returns

\Charcoal\Admin\Widget\FormPropertyWidget

setFormData()

setFormData(array  $data) : \Charcoal\Admin\Widget\ObjectFormWidget

Set the form's auxiliary data.

This method is called via \self::setData() if a "form_data" parameter is present on the HTTP request.

Parameters

array $data

Data.

Returns

\Charcoal\Admin\Widget\ObjectFormWidget

Chainable.

formData()

formData() : array

Retrieve the form's auxiliary data.

Returns

array

objData()

objData() : array

Object data.

Returns

array —

Object data.

setModelFactory()

setModelFactory(\Charcoal\Factory\FactoryInterface  $factory) : \Charcoal\Admin\AdminScript

Parameters

\Charcoal\Factory\FactoryInterface $factory

The factory used to create models.

Returns

\Charcoal\Admin\AdminScript

Chainable

modelFactory()

modelFactory() : \Charcoal\Factory\FactoryInterface

Returns

\Charcoal\Factory\FactoryInterface —

The model factory.

createOrLoadObj()

createOrLoadObj() : \Charcoal\Model\ModelInterface

Create or load the object.

Returns

\Charcoal\Model\ModelInterface

cloneObj()

cloneObj() : \Charcoal\Model\ModelInterface

Throws

\Exception

If the object is not valid.

Returns

\Charcoal\Model\ModelInterface

createObjFromBluePrint()

createObjFromBluePrint() : \Charcoal\Model\ModelInterface

Throws

\Exception

If the object is not valid.

Returns

\Charcoal\Model\ModelInterface

createObj()

createObj() : \Charcoal\Model\ModelInterface

Throws

\Exception

If the object is not valid.

Returns

\Charcoal\Model\ModelInterface

loadObj()

loadObj() : \Charcoal\Model\ModelInterface

Returns

\Charcoal\Model\ModelInterface —

The loaded object

validateObjType()

validateObjType() : boolean

Throws

\RuntimeException

If the object is invalid.

Returns

boolean

validateObjBaseClass()

validateObjBaseClass(mixed  $obj) : boolean

Parameters

mixed $obj

Object to validate.

Returns

boolean

setHttpRequest()

setHttpRequest(\Psr\Http\Message\RequestInterface  $request) : self

Set an HTTP request object.

Parameters

\Psr\Http\Message\RequestInterface $request

A PSR-7 compatible Request instance.

Returns

self

setWidgetFactory()

setWidgetFactory(\Charcoal\Factory\FactoryInterface  $factory) : self

Set an widget factory.

Parameters

\Charcoal\Factory\FactoryInterface $factory

The factory to create widgets.

Returns

self

widgetFactory()

widgetFactory() : \Charcoal\Factory\FactoryInterface

Retrieve the widget factory.

Throws

\RuntimeException

If the widget factory was not previously set.

Returns

\Charcoal\Factory\FactoryInterface

dataFromRequest()

dataFromRequest() : array

Fetch metadata from the current request.

Returns

array

acceptedRequestData()

acceptedRequestData() : array

Retrieve the accepted metadata from the current request.

Returns

array

addDataSources()

addDataSources(mixed  $sourceIdent, mixed  $sourceFilter = null) : \Charcoal\Admin\AdminWidget

Set extra data sources to merge when setting data on an entity.

Parameters

mixed $sourceIdent

The data source identifier.

mixed $sourceFilter

Optional filter to apply to the source's data.

Throws

\InvalidArgumentException

If the data source is invalid.

Returns

\Charcoal\Admin\AdminWidget

Chainable

acceptedDataSources()

acceptedDataSources() : array<mixed,string>

Retrieve the available data sources (when setting data on an entity).

Returns

array<mixed,string>

defaultDataSources()

defaultDataSources() : array<mixed,string>

Retrieve the default data sources (when setting data on an entity).

Returns

array<mixed,string>

defaultDataSourceFilters()

defaultDataSourceFilters() : array

Retrieve the default data source filters (when setting data on an entity).

Returns

array

resolveDataSourceFilter()

resolveDataSourceFilter(mixed  $toResolve) : callable|null

Retrieve the default data source filters (when setting data on an entity).

Note: Adapted from \Slim\CallableResolver.

Parameters

mixed $toResolve

A callable used when merging data.

Returns

callable|null

mergeDataSources()

mergeDataSources(array|\Charcoal\Admin\ArrayInterface  $dataset = null) : \Charcoal\Admin\AdminWidget

Retrieve the available data sources (when setting data on an entity).

Parameters

array|\Charcoal\Admin\ArrayInterface $dataset

The entity data.

Returns

\Charcoal\Admin\AdminWidget

Chainable

dataFromObject()

dataFromObject() : array

Fetch metadata from the current object type.

Returns

array

createFormGroup()

createFormGroup(array|null  $data = null) : \Charcoal\Ui\FormGroup\FormGroupInterface

Create a new form group widget.

Parameters

array|null $data

Optional. The form group data to set.

Returns

\Charcoal\Ui\FormGroup\FormGroupInterface

updateFormGroup()

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

Update the given form group widget.

Parameters

\Charcoal\Ui\FormGroup\FormGroupInterface $group

The form group to update.

array|null $groupData

Optional. The new group data to apply.

string|null $groupIdent

Optional. The new group identifier.

Returns

\Charcoal\Ui\FormGroup\FormGroupInterface