NestedForm widget


Public Properties

public array $form

form configuration

public bool $showPanel

showPanel defines if the nested form is styled like a panel

public bool $defaultCreate

defaultCreate will create a new record when the form loads, useful for associating relations within the nested form

Show inherited public properties

Inherited Public Properties

Protected Properties

protected $defaultAlias

defaultAlias to identify this widget.

protected bool $useRelation

useRelation will instruct the widget to look for a relationship

protected Backend\Widgets\Form $formWidget

formWidget reference

protected Model $relatedRecord

relatedRecord when using a relation

protected array $modelsToSave

modelsToSave are models that require saving

Show inherited protected properties

Inherited Protected Properties

Public Methods

public getSaveValue()

public getSaveValue($value): void

getSaveValue processes the postback value for this widget. If the value is omitted from postback data, the form widget will be skipped.

public init()

public init(): void

init the widget, called by the constructor and free from its parameters.

public nearestModelAttribute()

public nearestModelAttribute($attribute): void

public prepareVars()

public prepareVars(): void

prepareVars for display

public render()

public render(): void

render the widget's primary contents.

public resetFormValue()

public resetFormValue(): void

resetFormValue from the form field

public resolveModelAttribute()

public resolveModelAttribute(string $attribute): array 

Returns the final model and attribute name of a nested HTML array attribute. Eg: [$model, $attribute] = $this->resolveModelAttribute($this->valueFrom);

Show inherited public methods

Inherited Public Methods

Protected Methods

protected createRelationByDefault()

protected createRelationByDefault(): void

protected deferPurgedSaveAttributes()

protected deferPurgedSaveAttributes(
    October\Rain\Database\Model $model,
    array $attributesToPurge
): void 

deferPurgedSaveAttributes removes an array of attributes from the model. If the model implements the Purgeable trait, this is preferred over the internal logic.

protected getLoadValueFromRelation()

protected getLoadValueFromRelation(): void

protected getRelationModel()

protected getRelationModel(): Relation 

Returns the model of a relation type, supports nesting via HTML array.

protected getRelationObject()

protected getRelationObject(): Relation 

Returns the value as a relation object from the model, supports nesting via HTML array.

protected getRelationType()

protected getRelationType(): string 

getRelationType returns the value as a relation type from the model, supports nesting via HTML array.

protected isRelationTypeSingular()

protected isRelationTypeSingular(): bool 

isRelationTypeSingular checks if the related model is singular.

protected loadAssets()

protected loadAssets(): void

protected makeNestedFormWidget()

protected makeNestedFormWidget(): void

makeNestedFormWidget creates a form widget

protected performSaveOnModel()

protected performSaveOnModel($model, $data, $options = null): void

performSaveOnModel saves complex data against a model inside a database transaction.

protected prepareModelsToSave()

protected prepareModelsToSave(
    October\Rain\Database\Model $model,
    array $saveData
): array 

prepareModelsToSave takes a model and fills it with data from a multidimensional array. If an attribute is found to be a relationship, that relationship is also filled.

$modelsToSave = $this->prepareModelsToSave($model, [...]);

foreach ($modelsToSave as $modelToSave) {

protected processRelationMode()

protected processRelationMode(): void

protected processSaveForRelation()

protected processSaveForRelation(array $value): array|null 

protected setModelAttributes()

protected setModelAttributes(
    October\Rain\Database\Model $model,
    array $saveData,
    $attrName = ''
): void 

setModelAttributes sets a data collection to a model attributes, relations are also set.

protected tagTabbedFormFields()

protected tagTabbedFormFields(&$config): void

tagTabbedFormFields adds is-nested CSS class to tabs

Show inherited protected methods

Inherited Protected Methods