#[derive(ActionInput)]
{
// Attributes available to this derive:
#[form]
}
Expand description
Derives ActionInput for the typed value an Action asks for
before it runs.
#[derive(tablo_core::ActionInput)]
pub struct Rejection {
#[form(multiline = 4)]
pub reason: String,
pub notify_author: bool,
}
struct Reject;
impl Action<PostResource> for Reject {
type Input = Rejection;
const NAME: &'static str = "reject";
async fn run(
_cx: &Cx,
posts: &[Post],
rejection: Rejection,
ex: &mut dyn toasty::Executor,
) -> Result<()> {
// Store `rejection.reason`, notify when `rejection.notify_author` holds…
Ok(())
}
}Each field posts its own name, which no column binds, and renders the control its type
picks: a bool a checkbox, #[form(options)] a choice over the field type’s
Options, #[form(options = T)] one over T’s, and any other
FormScalar a text input of the type’s input type.
A field’s blank answer is its #[form(blank = ..)], "" for an #[form(optional)]
String, None for an Option, or false for a bool. A field with none is required:
its control renders required and the parse refuses an empty submission.
§Per-field attributes
#[form(label = "Reason")]— the control’s label (default: the field name in sentence case).#[form(multiline = 4)]— a<textarea>of 4 rows.#[form(placeholder = "rust, async")]— a text input’s placeholder.#[form(email)]— a text input that refuses a malformed email address.#[form(password)]— a masked text input on aString, read untrimmed, that a refused form renders empty.#[form(blank = ..)],#[form(optional)]— the blank answer.#[form(options)],#[form(options = T)]— a choice. AnOption<T>field names its options type:#[form(options = T)].
A generic struct, a tuple struct, an empty struct (name () instead), an unknown key, a
text input’s key with options or on a bool, password with multiline, and a field
that is not a FormScalar are compile errors.
RouterBuilderPanelExt::panel refuses a field named csrf_token, confirm or ids,
the keys an action’s POST carries besides its input.
A hand-written impl builds its fields with Field::text_input, Field::choice_input
and Field::toggle_input; its controls render without the required mark, though its
parse still refuses what it requires.
Derive ActionInput for the typed value an action asks for; documented on the tablo-core
re-export.