#[derive(EmbeddedForm)]
{
// Attributes available to this derive:
#[form]
}
Expand description
Derives EmbeddedForm for an embedded struct or enum.
Builds the schema node and converts the value through that node’s keys.
#[derive(Debug, Clone, toasty::Embed, tablo_core::EmbeddedForm)]
pub enum Publication {
#[column(variant = 1)]
Scheduled {
#[shared(timestamp)]
#[form(label = "Publication timestamp")]
scheduled_at: String,
scheduled_for: String,
},
#[column(variant = 2)]
Published {
#[shared(timestamp)]
published_at: String,
canonical_url: String,
},
}
// form declaration — no field bindings written by hand
Section::new("Publication").schema(Publication::form(Post::fields().publication()));§How a field is classified
A field marked #[form(embed)] is another embedded value, delegated to
its own EmbeddedForm. Every other field is a scalar: one column, read
and written through FormScalar (String, a TypedValue type, or an
Option of one). A scalar of another type fails to compile at the field,
naming the trait. An empty scalar is its declared #[form(blank = ..)],
else its FormScalar::blank(); with neither, the parse refuses its key.
§Which variant an enum reads
A named discriminant always wins, and an undeclared one is refused;
otherwise the first variant, in declaration order, with a payload of its
own submitted — a #[shared(..)] column belongs to several variants and
never selects one; otherwise the first variant.
§Per-field attributes
#[form(embed)]— a nestedEmbeddedFormvalue.#[form(label = "Canonical URL")]— the control’s label (default: the field name, humanized).#[form(multiline = 3)]— a<textarea>of 3 rows.#[form(blank = ..)]— what an empty submission reads as, overriding the leaf type’s own answer.
Anything else in #[form(..)] is a compile error, as are label, multiline, and blank
on an embedded value.
Derives EmbeddedForm for an embedded struct or enum; documented on the tablo-core re-export.