pub struct Inline {
pub target_model: &'static str,
pub fk_field: &'static str,
pub label: Option<&'static str>,
pub max_rows: usize,
pub display_field: Option<&'static str>,
}Expand description
One related-children section to render below a parent model’s
edit form. v1 surface: read-only listing of up to max_rows
children matching <target.fk_field> = <parent.id>, each row
a click-through to its own edit page, with an “Add new …”
link that lands the operator on the child’s new form (the
operator fills the parent FK manually for now).
Project authors declare these on the parent via
ModelAdmin::inlines:
fn inlines() -> &'static [Inline] {
&[Inline {
target_model: "Appointment",
fk_field: "patient_id",
label: Some("Appointments"),
max_rows: 50,
}]
}target_model must match a registered admin entry’s
SINGULAR_NAME. fk_field is the column on the child that
holds the parent’s id. A typo in either name silently renders
an empty section.
Fields§
§target_model: &'static str§fk_field: &'static str§label: Option<&'static str>Section title. None → fall back to the target model’s
display_name.
max_rows: usizeCap how many children are fetched + rendered. Operators who need to see the rest follow a “…and N more” link to the target’s list page pre-filtered to this parent.
display_field: Option<&'static str>Column on the target whose value is rendered as each
inline row’s clickable label. None falls through the
framework’s display-field ladder (name → title → full_name → email) and finally to #<id>. Set this for
child models without a natural-name column (e.g.
Appointment.status or Loan.borrowed_at).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Inline
impl RefUnwindSafe for Inline
impl Send for Inline
impl Sync for Inline
impl Unpin for Inline
impl UnsafeUnpin for Inline
impl UnwindSafe for Inline
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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