pub struct Form {
pub message: String,
pub fields: Vec<FormField>,
/* private fields */
}Expand description
Form supports two interaction modes based on field count:
- Single-step mode (
0or1fields) - Multi-step mode (
2+fields)
In both modes, each FormField renders through its backing widget and all values can be serialized with to_json().
§Modes
§Single-step mode (0 or 1 fields)
The form renders only the active prompt content and footer hints.
- No tab bar
- No review/submit pane
Entersubmits immediately
This mode is ideal for yes/no confirmations and other one-question prompts.
§Multi-step mode (2+ fields)
A tab bar is shown with all fields plus a virtual Submit tab.
- Navigate with
Tab/BackTabor arrows (for non-text fields) Enteradvances to the next tab while editing fieldsEnteron the Submit tab emits submit
The Submit tab shows a review summary of all field values.
§Messages
Form implements Component with Message = FormMessage:
FormMessage::Close— Emitted onEsc.FormMessage::Submit— Emitted onEnter:- immediately in single-step mode
- only from the Submit tab in multi-step mode
§FormField
A single field within the form:
name— Machine-readable key (used in JSON output).label— Human-readable label shown in UI.description— Optional help text shown below the field.required— Iftrue, an asterisk is shown next to the label.kind— The backing widget, as aFormFieldKind.
§FormFieldKind
Text(TextField)— Single-line text input.Number(NumberField)— Numeric input.Boolean(Checkbox)— Toggle rendered as[x]/[ ].SingleSelect(RadioSelect)— Radio button list.MultiSelect(MultiSelect)— Checkbox list.
§See also
Fields§
§message: String§fields: Vec<FormField>Implementations§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Form
impl RefUnwindSafe for Form
impl Send for Form
impl Sync for Form
impl Unpin for Form
impl UnsafeUnpin for Form
impl UnwindSafe for Form
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
Mutably borrows from an owned value. Read more
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>
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 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>
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