Repository navigation
feat!: define meta fields as typed properties using the form system - #6760
Merged
Merged
Conversation
A meta schema now declares its fields as properties annotated with form field types instead of yielding `MetaField` objects. The columns are named after the field keys (the property name in snake_case or an explicit `key`) with the `meta_` prefix, their types are derived from the field and property types (`float` → `double`, `BcMath\Number` → `decimal` with the scale of the field's step). `#[Translated]` marks fields stored per language, `isFieldAllowed()` restricts fields to a context, `validate()` checks across fields. `MetaSchema::of($item)` returns the typed values of an article, category, medium or language. An entity may now have several schemas. The handlers embed one form per schema into the forms of the entities. Submitted values are validated now; invalid ones are not saved. The article meta form shows the errors at the fields, categories and media report them via `UserMessageException`. `Column::double()` is added for the approximate number columns.
The meta sidebar of the article is too narrow for labels next to the fields. `FieldRow` and `Form` get a `vertical` option for that, using the existing `rex-form-group-vertical` layout.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Moves meta info onto the new form system (#6754): a meta schema declares its fields as typed properties annotated with form field types, the same way as any other form data class. The old
MetaInfo\Field\*classes are removed.Schemas
meta_+ the field key, i.e. the property name in snake_case ($seoTitle→meta_seo_title) or an explicitkey– which also allows renaming a property without losing its column. The column types are derived from the field and property types (e.g.Text→varchar(maxLength ?? 255),Textareaand lists →text,Checkbox→bool, date pickers →date/datetime/time,float→double,BcMath\Number→decimalwith the scale of the field'sstep); a schema can override single columns viacolumn(). Lists are stored comma-separated, so they stay queryable viaFIND_IN_SET().Column::double()is added for this.#[Translated]marks fields stored per language (in the translation table of the entity).isFieldAllowed()restricts fields to a context (e.g. a category),validate()checks across fields.LogicException.MetaSchema::of($item)returns the meta values of an article, category, medium or language as a schema instance, shared per item. Missing values or values that do not fit the property type anymore keep the property default.Forms and validation
The handlers embed one form per schema into the forms of the entities (
Form::submit()/onlyfrom #6754). Submitted values are validated now – before, they were saved without any checks – and invalid values are not saved:CategoryAdded/CategoryUpdated/MediaAdded/MediaUpdated), so the entity is saved already; the errors are reported viaUserMessageException("The metadata has not been saved: …"), which the API functions and the media pool show as error message.Validating the meta values before the entity is saved would need meta info to be integrated into the handlers directly instead of via extension points – possible now that meta info is part of the core, but left for a follow-up.
Also fixed
Categoryobject.