Infolists
Infolists are the “show” side of a resource — a definition list of entries over a record.
from almasix.orbit.infolists import ( Infolist, TextEntry, ImageEntry, CodeEntry, KeyValueEntry, RepeatableEntry,)
infolist = Infolist.make("post").schema([ TextEntry.make("title").badge().color("success"), TextEntry.make("slug").copyable(), TextEntry.make("body").prose().markdown(), ImageEntry.make("cover"), CodeEntry.make("payload"), KeyValueEntry.make("meta"), RepeatableEntry.make("tags").schema([ TextEntry.make("name"), ]),])
html = infolist.render(post)Markup is a <dl class="or-infolist"> — semantic, styleable, no surprise div soup.
Entry API
Section titled “Entry API”TextEntry.make("email") .label("Email") .format_state_using(lambda v: v.lower()) .url("mailto:{state}") .copyable() .badge() .color("info") .icon("heroicon-o-envelope") .date_time() .markdown() .prose()| Entry | Role |
|---|---|
TextEntry |
Default |
IconEntry |
Icon-forward |
ImageEntry |
Image |
ColorEntry |
Color swatch |
CodeEntry |
Monospace / code block |
KeyValueEntry |
Dict-ish display |
RepeatableEntry |
Nested entry schema |
On a resource
Section titled “On a resource”@classmethoddef infolist(cls, infolist: Infolist) -> Infolist: return infolist.schema([ TextEntry.make("title"), TextEntry.make("status").badge(), ])Then PostResource.get_infolist().render(record) on your view page.
Empty infolist → readonly form fallback
Section titled “Empty infolist → readonly form fallback”Leave infolist() empty (or return the untouched builder) and Orbit still gives you a show page. get_infolist() notices there are no components and projects the form schema into read-only TextEntrys:
@classmethoddef form(cls, form: Form) -> Form: return form.schema([ TextInput.make("title").required(), TextInput.make("slug").required(), Textarea.make("body"), ])
@classmethoddef infolist(cls, infolist: Infolist) -> Infolist: return infolist # empty on purposeUnder the hood:
get_form().readonly()— same fields, edit chrome dialed down.- Walk nested layouts / repeaters for every
Field. - Emit
TextEntry.make(name).label(field.get_label())for each.
So create/edit and view stay in sync until you’re ready to hand-craft badges, prose, and copyable slugs. Define an explicit .schema([...]) whenever the show page should look different from the form — the fallback politely steps aside.