pub struct RegisteredResource { /* private fields */ }Expand description
A runtime resource as the registry holds it: the definition, ready for the panel.
Implementations§
Source§impl RegisteredResource
impl RegisteredResource
Sourcepub fn resource(&self) -> &RuntimeResource
pub fn resource(&self) -> &RuntimeResource
The definition that was registered.
The label of the navigation entry: the navigation label, or the title.
The navigation group the resource is listed under, if any.
The resource’s place in the navigation, if set.
The name of the navigation entry’s icon, if set.
Sourcepub fn validate(&self, form: &FormInput) -> Result<Row, FieldErrors>
pub fn validate(&self, form: &FormInput) -> Result<Row, FieldErrors>
Turns the submitted form into a Row for a create, or returns one message per
field. It runs the same checks as a static resource, with the same messages:
required fields (Field::check_required), whole
numbers, decimals, dates, date-times and select choices. The row holds one key per
field:
- text, textarea, select, lookup: a string. A required value is trimmed.
- email, URL, radio, color, image, file, link, wysiwyg, post object, relationship,
taxonomy, user, repeater, group, flexible content, gallery, clone: the text
Field::check_valuereturns. The structured kinds hold JSON text. - number: an integer. Decimal: a number.
- checkbox:
trueorfalse; a checkbox is never blank. - date:
"YYYY-MM-DD". Date-time:"YYYY-MM-DD HH:MM:SS". - password: the hash of the password (
hash_password). - a blank field that is not required:
null.
Each error in FieldErrors is keyed by the field’s name, an owned String.
A lookup, post object, relationship, taxonomy or user value is checked against
RuntimeData::options by the panel, which can read the database, and so is a media
id against the registered MediaLibrary.
Sourcepub fn validate_update(&self, form: &FormInput) -> Result<Row, FieldErrors>
pub fn validate_update(&self, form: &FormInput) -> Result<Row, FieldErrors>
Turns the submitted form into a Row for an update. It is
validate, except that:
- a blank password is not an error: the row leaves its key out, so the stored password is kept;
- an optional field the form did not send at all (
FormInput::hasis false) is left out of the row, so its stored value is kept; - an optional field sent blank is
null, so clearing it on the edit form clears the stored value, as#[derive(IgniteResource)]does since 0.3.0; - a checkbox the form did not send is
false, because an unticked HTML checkbox sends nothing.
Sourcepub fn conditions(&self) -> &FieldConditions
pub fn conditions(&self) -> &FieldConditions
The conditions that show or hide the form’s fields.
Sourcepub fn validate_shown(
&self,
form: &FormInput,
hidden: &BTreeSet<String>,
) -> Result<Row, FieldErrors>
pub fn validate_shown( &self, form: &FormInput, hidden: &BTreeSet<String>, ) -> Result<Row, FieldErrors>
validate for a form whose fields hidden are hidden (see
FieldConditions::hidden_fields): they are not checked, a required one included, and
the row has no key for them, so the source writes nothing for them. The panel calls it.
Sourcepub fn validate_update_shown(
&self,
form: &FormInput,
hidden: &BTreeSet<String>,
) -> Result<Row, FieldErrors>
pub fn validate_update_shown( &self, form: &FormInput, hidden: &BTreeSet<String>, ) -> Result<Row, FieldErrors>
validate_update for a form whose fields hidden are hidden:
the row has no key for them, so their stored values are kept, whatever the form sent.
Auto Trait Implementations§
impl !RefUnwindSafe for RegisteredResource
impl !UnwindSafe for RegisteredResource
impl Forget for RegisteredResource
impl Freeze for RegisteredResource
impl Move for RegisteredResource
impl Send for RegisteredResource
impl Sync for RegisteredResource
impl Unpin for RegisteredResource
impl UnsafeUnpin for RegisteredResource
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
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> ⓘ
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> ⓘ
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