pub struct RowScope<'a> { /* private fields */ }Expand description
A single row’s rendering scope inside inputs_for.
Each scope binds the child collection name, the row’s 0-based index, and
(for existing/submitted rows) the underlying NestedRow so its raw values
pre-fill inputs and its per-subfield errors render inline on re-render after
a failed submission. A blank template row carries row: None — its inputs
render empty with no error blocks.
The row-scoped input builders mirror the standalone field helpers in
crate::form (text_input, number_input, …) but emit nested input
names (items[{index}][{sub}]) and per-row-unique element ids
(items-{index}-{sub}) so ids and aria-describedby links stay unique
across repeated rows.
Implementations§
Source§impl RowScope<'_>
impl RowScope<'_>
Sourcepub fn field_name(&self, sub: &str) -> String
pub fn field_name(&self, sub: &str) -> String
The nested input name for subfield sub, i.e.
"{collection}[{index}][{sub}]".
Sourcepub fn value(&self, sub: &str) -> Option<&str>
pub fn value(&self, sub: &str) -> Option<&str>
The raw submitted value for subfield sub, or None for a blank row.
Sourcepub fn errors_for(&self, sub: &str) -> &[String]
pub fn errors_for(&self, sub: &str) -> &[String]
Validation messages for subfield sub, or an empty slice (always empty
for a blank row).
Sourcepub fn is_destroyed(&self) -> bool
pub fn is_destroyed(&self) -> bool
true when this (existing) row carried a truthy _destroy marker.
Sourcepub fn text_input(&self, sub: &str, label: &str) -> Markup
pub fn text_input(&self, sub: &str, label: &str) -> Markup
Render a labeled row-scoped <input type="text"> for subfield sub.
Mirrors crate::form::text_input: autumn-field wrapper, per-row
pre-fill, aria-invalid / aria-describedby, and a role="alert"
error block — but with the nested name and a per-row-unique id.
Sourcepub fn required_text_input(&self, sub: &str, label: &str) -> Markup
pub fn required_text_input(&self, sub: &str, label: &str) -> Markup
Like RowScope::text_input but adds required + aria-required="true"
— only for real/submitted rows that are not marked for destruction
(self.row.is_some() && !self.is_destroyed()).
A blank template row (row: None, the one inputs_for auto-appends
for the no-JS “add a child” path) deliberately renders the same input
without the client-side required/aria-required attributes so it
stays leaveable-empty. Otherwise the browser’s native constraint
validation would block form submit on the empty trailing template row
before the server’s all-blank rejection can run — a user who filled one
child row could not submit while a blank row sat beneath it. A submitted
row the user ticked _destroy on is skipped for the same reason: the
decoder drops destroyed rows before validation (and from into_valid()),
so re-emitting client-side required on an empty destroyed field would
let the browser block the next submit before the server can honor the
removal. Required-ness is still enforced server-side for any row the user
actually engages: a partially-filled, non-destroyed row is retained as a
Some row on re-render and re-acquires required, and the decoder’s
all-blank rejection drops the untouched template row. This composes with
that all-blank rejection so
neither the client nor the server treats the template row as a real child.
Sourcepub fn number_input(&self, sub: &str, label: &str) -> Markup
pub fn number_input(&self, sub: &str, label: &str) -> Markup
Render a labeled row-scoped <input type="number"> for subfield sub.
Mirrors crate::form::number_input (leaving the browser-default
step), with the nested name and a per-row-unique id.
Sourcepub fn textarea_input(&self, sub: &str, label: &str) -> Markup
pub fn textarea_input(&self, sub: &str, label: &str) -> Markup
Render a labeled row-scoped <textarea> for subfield sub.
Mirrors crate::form::textarea_input: the value is emitted as the
element body, with the nested name and a per-row-unique id.
Render a row-scoped <input type="hidden"> for subfield sub.
Use this to carry an existing child’s primary key (e.g. id) on an edit
form so the decoder can match the submitted row back to a persisted record.
Sourcepub fn destroy_checkbox(&self, label: &str) -> Markup
pub fn destroy_checkbox(&self, label: &str) -> Markup
Render the durable no-JS removal control: a _destroy checkbox whose
checked state is preserved on re-render (checked iff
RowScope::is_destroyed).
The decoder honours a truthy _destroy marker
(decode_nested_urlencoded), so ticking this box and submitting the
surrounding form removes the row with no JavaScript. htmx/JS row removal
(swapping the .nested-fields__row node’s outerHTML) is an optional
progressive enhancement layered on top; this checkbox is the required
mechanism.
Auto Trait Implementations§
impl<'a> Freeze for RowScope<'a>
impl<'a> RefUnwindSafe for RowScope<'a>
impl<'a> Send for RowScope<'a>
impl<'a> Sync for RowScope<'a>
impl<'a> Unpin for RowScope<'a>
impl<'a> UnsafeUnpin for RowScope<'a>
impl<'a> UnwindSafe for RowScope<'a>
Blanket Implementations§
Source§impl<T> AggregateExpressionMethods for T
impl<T> AggregateExpressionMethods for T
Source§fn aggregate_distinct(self) -> Self::Outputwhere
Self: DistinctDsl,
fn aggregate_distinct(self) -> Self::Outputwhere
Self: DistinctDsl,
DISTINCT modifier for aggregate functions Read moreSource§fn aggregate_all(self) -> Self::Outputwhere
Self: AllDsl,
fn aggregate_all(self) -> Self::Outputwhere
Self: AllDsl,
ALL modifier for aggregate functions Read moreSource§fn aggregate_filter<P>(self, f: P) -> Self::Output
fn aggregate_filter<P>(self, f: P) -> Self::Output
Source§fn aggregate_order<O>(self, o: O) -> Self::Outputwhere
Self: OrderAggregateDsl<O>,
fn aggregate_order<O>(self, o: O) -> Self::Outputwhere
Self: OrderAggregateDsl<O>,
Source§impl<T> AutumnDependents for Twhere
T: ?Sized,
impl<T> AutumnDependents for Twhere
T: ?Sized,
Source§fn dependents() -> &'static [RuntimeDependentSpec]
fn dependents() -> &'static [RuntimeDependentSpec]
#[model] overrides via an inherent shadow when dependents exist.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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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> IntoSql for T
impl<T> IntoSql for T
Source§fn into_sql<T>(self) -> Self::Expression
fn into_sql<T>(self) -> Self::Expression
self to an expression for Diesel’s query builder. Read moreSource§fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
&self to an expression for Diesel’s query builder. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T, Conn> RunQueryDsl<Conn> for T
impl<T, Conn> RunQueryDsl<Conn> for T
Source§fn execute<'conn, 'query>(
self,
conn: &'conn mut Conn,
) -> <Conn as AsyncConnectionCore>::ExecuteFuture<'conn, 'query>
fn execute<'conn, 'query>( self, conn: &'conn mut Conn, ) -> <Conn as AsyncConnectionCore>::ExecuteFuture<'conn, 'query>
Source§fn load<'query, 'conn, U>(
self,
conn: &'conn mut Conn,
) -> AndThen<Self::LoadFuture<'conn>, TryCollect<Self::Stream<'conn>, Vec<U>>>
fn load<'query, 'conn, U>( self, conn: &'conn mut Conn, ) -> AndThen<Self::LoadFuture<'conn>, TryCollect<Self::Stream<'conn>, Vec<U>>>
Source§fn load_stream<'conn, 'query, U>(
self,
conn: &'conn mut Conn,
) -> Self::LoadFuture<'conn>where
Conn: AsyncConnectionCore,
U: 'conn,
Self: LoadQuery<'query, Conn, U> + 'query,
fn load_stream<'conn, 'query, U>(
self,
conn: &'conn mut Conn,
) -> Self::LoadFuture<'conn>where
Conn: AsyncConnectionCore,
U: 'conn,
Self: LoadQuery<'query, Conn, U> + 'query,
Stream] with the returned rows. Read moreSource§fn get_result<'query, 'conn, U>(
self,
conn: &'conn mut Conn,
) -> AndThen<Self::LoadFuture<'conn>, LoadNext<Pin<Box<Self::Stream<'conn>>>>>
fn get_result<'query, 'conn, U>( self, conn: &'conn mut Conn, ) -> AndThen<Self::LoadFuture<'conn>, LoadNext<Pin<Box<Self::Stream<'conn>>>>>
Source§fn get_results<'query, 'conn, U>(
self,
conn: &'conn mut Conn,
) -> AndThen<Self::LoadFuture<'conn>, TryCollect<Self::Stream<'conn>, Vec<U>>>
fn get_results<'query, 'conn, U>( self, conn: &'conn mut Conn, ) -> AndThen<Self::LoadFuture<'conn>, TryCollect<Self::Stream<'conn>, Vec<U>>>
Vec with the affected rows. Read moreSource§impl<T> Scoped for T
impl<T> Scoped for T
Source§fn scope(ctx: &PolicyContext) -> ScopeQuery<'_, Self>
fn scope(ctx: &PolicyContext) -> ScopeQuery<'_, Self>
ScopeQuery for this type. Resolves the
registered scope at .load() time, not here.