CoolCMS API

AssetVariantFormTrait

Form of one image variant (`Admin:System:AssetVariant`, add/edit).

The rules are the same as in the Api (AssetVariantPlan::validateVariant()); they are checked up front so the error attaches to a field, and the Api remains the authority (AssetVariantManager::beforeSave()). The name is immutable after creation: on edit the field is read-only and the Api does not take it from the payload.

Table of Contents

Methods

createComponentEditForm()  : Form
applyAssetVariantErrors()  : void
saveAssetVariantForm()  : bool
setAssetVariantFormDefaults()  : void

Methods

applyAssetVariantErrors()

private applyAssetVariantErrors(Form $form, array<int, array{code: string, field: string, other: string|null}> $errors) : void
Parameters
$form : Form
$errors : array<int, array{code: string, field: string, other: string|null}>

saveAssetVariantForm()

private saveAssetVariantForm(ArrayHash<string|int, mixed> $values, Form $form) : bool
Parameters
$values : ArrayHash<string|int, mixed>
$form : Form
Return values
bool
On this page

Search results