pub enum WidgetKind {
Show 32 variants
Text,
Textarea,
Markdown,
RichText,
Email,
Url,
Tel,
Password,
Hidden,
Number,
Integer,
Float,
Range,
Boolean,
Date,
Time,
Datetime,
DatetimeTz,
Color,
File,
MediaPicker,
PageChooser,
SnippetChooser,
SnippetM2M,
DocumentChooser,
ModelChooser,
Radio,
Select,
Checkboxes,
MultiSelect,
Stream,
Custom,
}Expand description
Which form input to draw. Templates dispatch on this variant via
the bundled rcms_admin/_widget.html Tera macro.
Serialized as a flat lowercase string ("text", "datetimetz",
"multiselect", …) so {% if w.kind == "datetimetz" %} matches
every template author intuitively.
Custom widgets keep the kind as "custom"; the third-party
widget’s wire name lives in Widget::custom_name so the macro
can dispatch to the right registered template.
Variants§
Text
Single-line <input type="text">.
Textarea
Multi-line <textarea> — plain content.
Markdown
Multi-line <textarea> with a “preview as markdown” affordance.
Rendered through crate::markdown::render on the public site.
RichText
Rich-text WYSIWYG widget (v1: same shape as Markdown — a
<textarea> with data-widget="richtext" to which host apps
can attach their own enhancer, e.g. EasyMDE / TipTap).
<input type="email"> — browser validates the shape.
Url
<input type="url">.
Tel
<input type="tel">.
Password
<input type="password">. Rare in a CMS surface but
completes the set (e.g. for storing API keys on snippets).
Hidden
<input type="hidden"> — passes values through without
drawing an input.
Number
<input type="number">. No min/max bound by default.
Integer
<input type="number"> constrained to integers.
Float
<input type="number" step="any"> for free-form decimals.
Range
<input type="range"> slider — pair with min/max/step.
Boolean
Single <input type="checkbox"> — present-or-absent.
Date
<input type="date">. Stored as ISO-8601 YYYY-MM-DD.
Time
<input type="time">. Stored as HH:MM[:SS].
Datetime
<input type="datetime-local">. Stored as
YYYY-MM-DDTHH:MM[:SS] (no timezone).
DatetimeTz
Pair of <input type="datetime-local"> + a timezone
<select> (IANA names). Value is the RFC 3339 string the
public-side renderer can parse with chrono::DateTime.
Color
<input type="color"> — hex #RRGGBB.
File
<input type="file"> — raw upload, no library indirection.
Distinct from Self::MediaPicker (which picks an existing
cms_media row by id).
MediaPicker
Media library picker — value is the cms_media.id as a
stringified integer. Empty = no selection.
PageChooser
Page chooser — modal <dialog> overlay listing pages by
title; value is the cms_page.id as a stringified integer.
Empty = no selection. Backs the
PageChooserBlock + any FK-to-page extension field.
SnippetChooser
Snippet chooser — modal <dialog> overlay listing snippets
(optionally filtered to one type_name via
Widget::custom_name); value is the cms_snippet.id as a
stringified integer. Backs the
SnippetChooserBlock.
SnippetM2M
Snippet many-to-many chooser — multi-select chooser listing
snippets of one type_name (in Widget::custom_name);
value is a JSON-array string of selected cms_snippet.id
values in chooser order. Backs page ↔ snippet
many-to-many relations. Storage lives in the
cms_page_snippet_m2m through-table — the widget’s
Widget::name is the M2M relation_name, Widget::value
is the JSON array the editor submits. Hosts call
crate::page_snippet_m2m::replace_all from their
save_extension override and
crate::page_snippet_m2m::related_snippets from
load_extension (or public_context) until the derive-macro
hook lands to do that wiring automatically.
DocumentChooser
Document chooser — modal <dialog> overlay listing media
rows of kind = "document"; value is the cms_media.id as
a stringified integer. Distinct from Self::MediaPicker
(which filters to images today). Backs the
DocumentChooserBlock.
ModelChooser
Generic model chooser — modal overlay over any
register_chooser!ed model. The registered chooser slug
lives in Widget::custom_name and becomes the
data-chooser-kind, which the cms-ux.js overlay resolves to
/cms-admin/__chooser/<slug>. Value is the chosen row’s id as
a stringified integer. Build with Widget::model_chooser.
Radio
Stacked <input type="radio"> group. Single-choice. Reads
(value, label) pairs from Widget::options.
Select
<select> dropdown. Single-choice. Reads from
Widget::options.
Checkboxes
Stacked <input type="checkbox"> group. Multi-choice; value
is a JSON array string. Reads from Widget::options.
MultiSelect
<select multiple>. Multi-choice; value is a JSON array
string. Reads from Widget::options.
Stream
StreamField — a list of composable blocks
(Heading / Paragraph / Image / Quote / nested two-column / …).
The list of allowed block types lives in Widget::allowed;
every entry must resolve to a registered crate::Block.
Storage shape: a JSON-array string of
{type, id, value} envelopes — see crate::block for the
full wire-format spec. Round-tripped through the editor as one
hidden form field; the admin macro renders the recursive
stream editor and the server deserializes the JSON on submit.
Custom
Third-party-registered widget. The wire name lives in
Widget::custom_name; look it up via
registry::find_custom_widget and render its template.
Implementations§
Source§impl WidgetKind
impl WidgetKind
Sourcepub fn as_tag(&self) -> &'static str
pub fn as_tag(&self) -> &'static str
Lowercase wire-format tag matching the serde rename. Used by
the template macro’s {% if w.kind == "…" %} arms and tests.
Sourcepub fn is_multi_value(&self) -> bool
pub fn is_multi_value(&self) -> bool
true for widgets whose wire contract POSTs a JSON-encoded
string in a single form field — Checkboxes / MultiSelect
(JSON arrays of strings), Stream (JSON array of block
envelopes), and SnippetM2M (JSON array of i64 snippet ids,
ordered).
Sourcepub fn is_translatable_text(&self) -> bool
pub fn is_translatable_text(&self) -> bool
true for widgets whose value is author-facing free text worth
translating per locale — single/multi-line text, Markdown source,
and RichText HTML. Everything else is structural (ids, numbers,
dates, choices) or an identifier (Email/Url/Tel) and is
never stored as a translation override. Drives the StreamField
translation walker in crate::block::translate.
Trait Implementations§
Source§impl Clone for WidgetKind
impl Clone for WidgetKind
impl Copy for WidgetKind
Source§impl Debug for WidgetKind
impl Debug for WidgetKind
Source§impl<'de> Deserialize<'de> for WidgetKind
impl<'de> Deserialize<'de> for WidgetKind
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for WidgetKind
Source§impl From<ExtensionFieldKind> for WidgetKind
impl From<ExtensionFieldKind> for WidgetKind
Source§fn from(k: ExtensionFieldKind) -> Self
fn from(k: ExtensionFieldKind) -> Self
Source§impl PartialEq for WidgetKind
impl PartialEq for WidgetKind
Source§impl Serialize for WidgetKind
impl Serialize for WidgetKind
impl StructuralPartialEq for WidgetKind
Auto Trait Implementations§
impl Freeze for WidgetKind
impl RefUnwindSafe for WidgetKind
impl Send for WidgetKind
impl Sync for WidgetKind
impl Unpin for WidgetKind
impl UnsafeUnpin for WidgetKind
impl UnwindSafe for WidgetKind
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more