Skip to main content

WidgetKind

Enum WidgetKind 

Source
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).

§

Email

<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

Source

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.

Source

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).

Source

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

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for WidgetKind

Source§

impl Debug for WidgetKind

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for WidgetKind

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for WidgetKind

Source§

impl From<ExtensionFieldKind> for WidgetKind

Source§

fn from(k: ExtensionFieldKind) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for WidgetKind

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for WidgetKind

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for WidgetKind

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AsOut<T> for T
where T: Copy,

Source§

fn as_out(&mut self) -> Out<'_, T>

Returns an out reference to self.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

Source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more