pub struct FieldMeta { /* private fields */ }Expand description
Signal-backed presentation metadata for one field-shaped value.
The flag meanings are producer-defined. This type does not track an initial value or classify validity. Error strings are already formatted for display before they cross this boundary.
Implementations§
Source§impl FieldMeta
impl FieldMeta
Sourcepub fn id(&self) -> Rc<str>
pub fn id(&self) -> Rc<str>
Returns the rendered control id.
Metadata always carries an id. When its producer supplies none,
use_field_meta_state generates one that is stable for the owning scope’s lifetime, so
Label’s for, aria-labelledby, aria-describedby, and aria-errormessage all
resolve instead of silently leaving the control unnamed.
Sourcepub fn set_id(&mut self, id: Option<Rc<str>>)
pub fn set_id(&mut self, id: Option<Rc<str>>)
Replaces the rendered control id, or restores the generated fallback with None.
Sourcepub fn set_required(&mut self, required: bool)
pub fn set_required(&mut self, required: bool)
Replaces the producer-defined required state.
Sourcepub fn set_disabled(&mut self, disabled: bool)
pub fn set_disabled(&mut self, disabled: bool)
Replaces the producer-defined disabled state.
Sourcepub fn invalid(&self) -> bool
pub fn invalid(&self) -> bool
Returns whether the field is invalid.
An explicit invalid state wins; otherwise invalidity is derived from whether errors exist.
Sourcepub fn set_invalid(&mut self, invalid: Option<bool>)
pub fn set_invalid(&mut self, invalid: Option<bool>)
Sets an explicit invalid state, or restores error-derived invalidity with None.
Sourcepub fn set_errors(&mut self, errors: Vec<Rc<str>>)
pub fn set_errors(&mut self, errors: Vec<Rc<str>>)
Replaces the pre-rendered error text.
Sourcepub fn set_touched(&mut self, touched: bool)
pub fn set_touched(&mut self, touched: bool)
Replaces the producer-defined touched state.
Sourcepub fn register_label_id(&mut self, id: Rc<str>) -> FieldMetaIdRegistration
pub fn register_label_id(&mut self, id: Rc<str>) -> FieldMetaIdRegistration
Registers a label element id until the returned registration is dropped.
Registered label ids reach the control through aria-labelledby, which is the only naming
path available to a control rooted on an element <label for> cannot address.
Sourcepub fn register_description_id(
&mut self,
id: Rc<str>,
) -> FieldMetaIdRegistration
pub fn register_description_id( &mut self, id: Rc<str>, ) -> FieldMetaIdRegistration
Registers a description element id until the returned registration is dropped.
Sourcepub fn register_error_id(&mut self, id: Rc<str>) -> FieldMetaIdRegistration
pub fn register_error_id(&mut self, id: Rc<str>) -> FieldMetaIdRegistration
Registers an error element id until the returned registration is dropped.
Sourcepub fn attributes(&self) -> Vec<Attribute>
pub fn attributes(&self) -> Vec<Attribute>
Returns attributes for a rendered control using the metadata’s own state, on a
FieldSurface::NATIVE element.
Sourcepub fn attributes_for(&self, options: &FieldControlOptions) -> Vec<Attribute>
pub fn attributes_for(&self, options: &FieldControlOptions) -> Vec<Attribute>
Returns attributes for a rendered control, resolving explicit overrides and the element’s attribute surface.
Overrides are resolved first and only the resolved state is emitted, so the caller never filters the result and no attribute appears twice.
§Guarantees
The returned vector is sorted by attribute name and carries at most one entry per attribute name and namespace.
The sort is what dioxus-core requires of any spread list: its attribute diff is a sorted
merge-join, so an unsorted list makes a later render drop attributes that did not change.
The single entry per name guards the neighbouring failure, where a spread carrying one name
twice and dropping to once emits a removal, deleting an attribute the new render still has.
To combine this with a widget’s own attributes, pass both to merge_attributes, which
preserves the guarantee and resolves each name last-wins. To replace a value the metadata
supplied, set the matching override on FieldControlOptions rather than adding a second
entry — that is what the overrides are for.
§Emitted attributes
id, always, from the override or the metadata.name, whenFieldSurface::nameisNameSurface::Nativeand a name resolves.requiredoraria-required="true", when required, perFieldSurface::required.disabledoraria-disabled="true", when disabled, perFieldSurface::disabled.aria-invalid, andaria-errormessagewhile invalid, perFieldSurface::validity.aria-errormessagetakes a single IDREF in ARIA 1.2, so it references only the first mounted error part; every error id also reachesaria-describedbywhile invalid.aria-labelledbyandaria-describedby, from the currently mounted parts. Both are legal on every role in play, so neither has a surface axis.data-required,data-disabled,data-invalid,data-touched, anddata-dirty, from the resolved state, absent when false and independent of the surface.
Sourcepub fn set_values(&mut self, values: FieldMetaValues)
pub fn set_values(&mut self, values: FieldMetaValues)
Replaces producer-owned metadata values without disturbing registered part ids.