A field of a source (ElementorexCms.Source): what the editor offers when a
prop of a block is bound to the data of an item.
key- the path of the value in a record ("name","category.name")label- shown in the editor (translated withElementorexCms.I18n)type- what the value is, so the editor can suggest it for the right props::string,:text(several lines),:html(rich text),:integer,:number,:boolean,:date,:datetime,:image(an image URL),:url,:color,:iconor:listsortable/filterable- whether loops can order and filter by itsearchable- whether the text search of the visitors' filters looks in it (default: text fields,:string,:textand:html)custom- a filter of the source with logic of its own (in_stock) rather than a value of the records: it can filter but not be shownrole- what the field means for templates generated from the source::title,:image,:description,:price(ornil)defaults- settings of new bindings to the field ("before","after","format","decimals","length","fallback"), e.g. a price that starts with"$". SeeElementorexCms.Dynamic
Summary
Functions
A field name in words: "image_url" → "Image URL", "category.name" →
"Category · Name".
Builds a field. key is a string or an atom; options are the keys of the
struct (:label, :type, :sortable, :filterable, :searchable,
:custom, :role, :defaults).
The label defaults to the key in words (image_url → "Image URL").
Roles a field can have (see the module docs).
The type of a text field guessed from its name: image, photo,
*_image_url… are :image; url, link, website, *_url are :url;
description, body, summary… are :text; *_html is :html; color
is :color; anything else :string.
Types a field can have.
Types
Functions
A field name in words: "image_url" → "Image URL", "category.name" →
"Category · Name".
Builds a field. key is a string or an atom; options are the keys of the
struct (:label, :type, :sortable, :filterable, :searchable,
:custom, :role, :defaults).
The label defaults to the key in words (image_url → "Image URL").
Field.new(:price, type: :number, sortable: true, defaults: %{"before" => "$"})
@spec roles() :: [atom()]
Roles a field can have (see the module docs).
The type of a text field guessed from its name: image, photo,
*_image_url… are :image; url, link, website, *_url are :url;
description, body, summary… are :text; *_html is :html; color
is :color; anything else :string.
iex> ElementorexCms.Source.Field.string_type("cover_image_url")
:image
iex> ElementorexCms.Source.Field.string_type("short_description")
:text
@spec types() :: [atom()]
Types a field can have.