Skip to content

ContentType's encoding form

By content type you have to define an encoding form. That form is defined by a structure of DataFields.

There is 6 different kinds of DataFields:

  • Simple: The DataFields the DataField corresponds to one, and only one, field in the elesticsearch mapping
  • Complex: The DataFields the DataField corresponds to many fields in the elesticsearch mapping
  • Compound: The DataFields is composed by other children DataFields, simple and complex children fields will be nested fields in elasticsearch's mapping
  • Layout: The DataFields doesn't correspond to anything in elasticsearch, it just about form's layout within the ElasticMS Admin interface
  • Mapping: The DataFields doesn't correspond to anything in the ElasticMS Admin interface, it just about the mapping of elasticsearch
  • JSON: The DataFields is composed by other children DataFields, simple and complex children fields will be serialized in a JSON text

You have several types of DataField available to define the form structure :

TypeKindIn the revision formIn elastisearchHas ChildDeprecated
AssetComplexMini app allowing to upload/download/drag-n-drop file(s)Array or array of array of meta information about files (hash, filename, filesize and mimetype)No
CheckboxSimpleCheckboxBooleanNo
ChoiceSimpleRadio buttons, Check boxes, Single-Select Combobox or Multi-Select ComboboxString or array of stringNo
CodeSimpleACE editortextNo
CollectionCompoundA dynamic and reorderable list of subformsnested objectMany
ColorSimpleA color pickertext or keywordNo
ComputedComplexNo input but a template in the revision viewfree defined mappingMay have
ContainerLayoutJust a container to organize children fields[N/A]Yes
CopyToMapping[N/A]Allow to defined mapping without form's fieldNo
DataLinkSimpleDocument pickerkeyword (string or array of strings)No
DateSimpleDate pickerdate (one or many)No
DateRangeComplexDate range picker2 dates (nested or not)No
DateTimeSimpleDate time pickerdateNo
EmailSimpleEmailtext or keywordNo
FormCompoundLoad the corresponding form entityLoad the corresponding form entityMany
HiddenSimpleNoUse a hidden class
HolderLayoutInvisible container[N/A]Many
IconSimpleFontAwsome 3 class pickertext or keywordNoAvoid it
IndexedAssetComplexMini app allowing to upload/download/drag-n-drop file(s) with Tika extractionsArray of meta information about files (hash, filename, filesize, mimetype, language, content, author, ...)No
IntegerSimpleText fieldintegerNo
JSONSimpleACE editorfree defined mappingNo
JsonMenuJSONSimple structure saved as a string in a JSONtext
JsonMenuLinkJSONLink to a JsonMenu nodetext
JsonMenuNestedEditorJSONComplex structure (with many subforms) saved as a string in a JSONtextMany (JSON encoded)
JsonMenuNestedLinkJSONLink to a JsonMenuNestedEditor nodetext
MultiplexedCompoundRender a form per value (form are selected via tab) can be integrated with a Tab fieldPrefixed all subfields (not nested) i.e. fr.titleMany
NestedCompoundSimilar to a container; organise children fieldsnested mappingMany
NumberSimpleText fielddoubleNo
OuuidSimpleNoUse the _id in a Computed field
PasswordSimplePassword fieldtext or keyword (the password is hashed)No
RadioSimpleNoUse a Choice field
SelectSimpleNoUse a Choice field
SubfieldMapping[N/A]Defined a submapping to the field. I.e. title.rawNo
TabsLayoutAllow to organize subforms in different tabs[N/A]Many (Containers)
TextStringSimpleText fieldNo
TextareaSimpleTextarea fieldtextNo
TimeSimpleTime pickerNo
VersionTagSimpleNo
WysiwygSimple[CK Editor](https://ckeditor.com/textNo

Postprocessing

It's a powerful way to validate, provide each form's DataField. It can be configured with a Twig template in the field's extra options tab.

Context of the postprocessing template:

  • _id: Document's OUUID (string) or null if the documents hasn't been finalized yet
  • migration: boolean set to true in the context of a migration (like in the context of the emsco:contenttype:migrate or ems:contenttype:recompute command)
  • finalize: boolean set to false in the context of an autosave, otherwize set to true
  • event: EMS\CoreBundle\Core\Revision\EventType. This object as the following parameters:
    • migrate: boolean set to true in the context of a migration (like in the context of the emsco:contenttype:migrate`` orems:contenttype:recompute` command)
    • finalize: boolean set to false in the context of an autosave, otherwize set to true
    • publish: boolean set to true in the context of a recompute on publish, only if the option 'Recompute on publish' is activated for the content type
    • draft: boolean set to true if it's not a finalisation
    • recompute: boolean set to true if it's a recompute (e.g. recompute command or recompute on publish)
    • import: boolean set to true if it's a revision that is migrated with the command emsco:contenttype:migrate or emsco:contenttype:import
    • autoSave: boolean set to true if it's an auto save
    • savedAsDraft: boolean set to true if it's a save as draft
    • reload: boolean set to true if data are reloaded during a reindex
  • rootObject: The associate array of the document's RAW data as it was extracted from the Revision's form
  • _source: The associate array of the current field with all its siblings (refers to data of the current DataField structure)
  • _type: content type's name (string)
  • index: Elasticsearch's alias of the content type's default environment
  • alias: Elasticsearch's alias of the content type's default environment
  • path: Dot path to the current DataField (i.e. 'fr.title')
  • form: Symfony Form object of the current DataField

Example of recompute on publish

In this example a counter publish_counter is incremented each time that a document is published in an environment but the default one.

twig
{%- if event.publish -%}
    {%- set counter = _source.publish_counter|default(0) -%}
    {{- counter + 1 -}}
{%- endif -%}