\Charcoal\Admin\Widget\FormGroupNestedWidgetFormGroup

Nested Widget Form Group

Allows UI widgets to be embedded into a form group and rendered using the current object, if any.

Based on WidgetFormGroup from beneroch/charcoal-utils.

Usage:

{
    "title": "My Nested Collection",
    "type": "charcoal/admin/widget/form-group/nested-widget",
    "widget_data": {
        "type": "charcoal/admin/widget/table",
        "obj_type": "foobar/model/item",
        "collection_ident": "grouped",
        "sortable": true
    },
    "renderable_data": {
        "collection_config": {
            "filters": [
                {
                    "property": "category",
                    "val": "{{ id }}"
                }
            ],
            "list_actions": [
                {
                    "ident": "create",
                    "url": "object/edit?obj_type=foobar/model/item&form_data[category]={{ id }}"
                }
            ]
        }
    }
}

Summary

Methods
Properties
Constants
widget()
getWidget()
setWidgetData()
mergeWidgetData()
addWidgetData()
widgetData()
defaultWidgetData()
widgetDataAsJson()
renderableData()
setRenderableData()
setDependencies()
widgetId()
setWidgetId()
description()
notes()
setShowNotes()
showNotesAbove()
No public properties found
No constants found
createWidget()
resolveWidget()
renderDataRecursive()
renderData()
widgetFactory()
setWidgetFactory()
$widget
N/A
parseDataToken()
filterDataToken()
$widgetData
$renderableData
$widgetId
$widgetFactory
$showNotesAbove
N/A

Properties

$widget

$widget : \Charcoal\App\Template\WidgetInterface

Store the nested widget.

Type

\Charcoal\App\Template\WidgetInterface

$widgetData

$widgetData : array

Settings for the nested widget.

Type

array

$renderableData

$renderableData : array

Settings, to be rendered, for the nested widget.

Type

array

$widgetId

$widgetId : string

Type

string

$widgetFactory

$widgetFactory : \Charcoal\Factory\FactoryInterface

Store the widget factory instance for the current class.

Type

\Charcoal\Factory\FactoryInterface

$showNotesAbove

$showNotesAbove : boolean

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

Type

boolean

Methods

widget()

widget() : \Charcoal\App\Template\WidgetInterface|\Charcoal\Admin\Ui\Generator

Yield the nested widget.

Returns

\Charcoal\App\Template\WidgetInterface|\Charcoal\Admin\Ui\Generator

getWidget()

getWidget() : \Charcoal\App\Template\WidgetInterface

Retrieve the nested widget.

Returns

\Charcoal\App\Template\WidgetInterface

setWidgetData()

setWidgetData(array  $settings) : self

Set the nested widget's options.

This method always merges default settings.

Parameters

array $settings

The nested widget options.

Returns

self

mergeWidgetData()

mergeWidgetData(array  $settings) : self

Merge (replacing or adding) nested widget options.

Parameters

array $settings

The nested widget options.

Returns

self

addWidgetData()

addWidgetData(string  $key, mixed  $val) : self

Add (or replace) an nested widget option.

Parameters

string $key

The setting to add/replace.

mixed $val

The setting's value to apply.

Throws

\InvalidArgumentException

If the identifier is not a string.

Returns

self

widgetData()

widgetData(string|null  $key = null, mixed|null  $default = null) : mixed

Retrieve the nested widget's options or a single option.

Parameters

string|null $key

The option key to lookup.

mixed|null $default

The fallback value to return if the $key doesn't exist.

Returns

mixed

defaultWidgetData()

defaultWidgetData() : array

Retrieve the default nested widget options.

Returns

array

widgetDataAsJson()

widgetDataAsJson() : string

Retrieve the nested widget's options as a JSON string.

Returns

string —

Returns data serialized with {@see json_encode()}.

renderableData()

renderableData() : array

Retrieve the nested widget's renderable options.

Returns

array

setRenderableData()

setRenderableData(array  $data) : self

Set the nested widget's renderable options.

Parameters

array $data

The data to render.

Returns

self

setDependencies()

setDependencies(\Pimple\Container  $container) : void

Parameters

\Pimple\Container $container

The DI container.

widgetId()

widgetId() : string

Retrieve the widget's ID.

Returns

string

setWidgetId()

setWidgetId(string  $widgetId) : self

Set the widget's ID.

Parameters

string $widgetId

The widget identifier.

Returns

self

description()

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

Returns

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

notes()

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

Returns

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

setShowNotes()

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

Show/hide the widget's notes.

Parameters

boolean|string $show

Whether to show or hide notes.

Returns

\Charcoal\Admin\Widget\FormGroup\FormGroupWidget —

Chainable

showNotesAbove()

showNotesAbove() : boolean

Returns

boolean

createWidget()

createWidget() : \Charcoal\App\Template\WidgetInterface

Create the nested widget.

Returns

\Charcoal\App\Template\WidgetInterface

resolveWidget()

resolveWidget(string  $type) : \Charcoal\App\Template\WidgetInterface

Resolve the nested widget.

Parameters

string $type

The widget to create.

Throws

\InvalidArgumentException

If the widget is invalid.

Returns

\Charcoal\App\Template\WidgetInterface

renderDataRecursive()

renderDataRecursive(array|\Traversable  $data) : array|\Traversable

Render the given data recursively.

Parameters

array|\Traversable $data

The data to render.

Throws

\InvalidArgumentException

If the data is not iterable.

\RuntimeException

If the form doesn't have a model.

Returns

array|\Traversable —

The rendered data.

renderData()

renderData(string  $data) : string

Render the given data.

Parameters

string $data

The data to render.

Returns

string —

The rendered data.

widgetFactory()

widgetFactory() : \Charcoal\Factory\FactoryInterface

Retrieve the widget factory.

Throws

\RuntimeException

If the widget factory was not previously set.

Returns

\Charcoal\Factory\FactoryInterface

setWidgetFactory()

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

Set the widget factory.

Parameters

\Charcoal\Factory\FactoryInterface $factory

The factory to create widgets.

Returns

self

parseDataToken()

parseDataToken(string|array  $token) : string

Parse the given slug (URI token) for the current object.

Parameters

string|array $token

The token to parse relative to the model entry.

Throws

\InvalidArgumentException

If a route token is not a string.

Returns

string

filterDataToken()

filterDataToken(mixed  $value, string  $token = null) : string

Filter the given value for a URI.

Parameters

mixed $value

A value to filter.

string $token

The parsed token.

Returns

string —

The filtered $value.