Backend\Traits\FormModelSaver

Source: ~/modules/backend/traits/FormModelSaver.php

Implements special logic for processing form data, typically from from postback, and filling the model attributes and attributes of any related models. This is a customized, safer and simplified version of $model->push().

Protected properties

protected array $modelsToSave

List of prepared models that require saving.

Protected methods

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

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

Parameters

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

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) {
    $modelToSave->save();
}
Parameters

protected void setModelAttributes(October\Rain\Database\Model $model, array $saveData)

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

Parameters