Form layout customization
Last updated
Last updated
This is the official documentation of the forestadmin-agent-django
and forestadmin-agent-flask
Python agents.
The form layout feature lets you organize your fields in pages or rows, and add separators or html blocks. This is especially useful if you have many fields to display, and you want to break down your action form into more manageable chunks !
Theses form elements are available since the version 1.16.0
of the agent.
Some layouts items will have options, but here are the common properties to all the layout elements
This item doesn't have specific options.
Example:
Example:
Example:
The pages feature is a way to break up your action form into more manageable chunks, by showing only a subset of fields at the same time, and letting the user navigate between the pages.
Please note this list of limitations:
You cannot mix fields and pages at the root of your form, or put nest a page in a page
The next (or previous) button is not clickable on the last (or first) page
Example:
This element is designed to work with only two inner fields. You can control the display of each field using the if_
property. If only one field is displayed, it will occupy the entire line. However, if the conditions defined by the if_
properties result in more than two fields being displayed, only the first two will be shown. If there is nothing inside, it will be removed.
If you're using if conditions in a page; keep in mind that if all the elements in your page are hidden, the page will automatically be removed. You can avoid this by behavior by adding an unconditional inside your page explaining why is your page empty.
component
required
"Separator"
To enable this component
component
required
"HtmlBlock"
To enable this component
content
required
String or callable with context parameter, returning a string formatted as html
This is the HTML content to show
component
required
"Page"
To enable this component
elements
required
Array of fields and layout elements
The layout elements defined in this page and the fields defined in the others documentation
next_button_label
optional
String
The label on the next
button
previous_button_label
optional
String
The label on the previous
button
None
Allow to add a horizontal separator between two form elements
None
Allow to show HTML content
Fields
Allow to put two (and only two) fields (and not layout elements) in a row
Fields & layouts elements (but no pages)
type
required
Layout
It differentiate a field
from layout
elements. See over values in static form documentation
component
required
Separator
, Row
, HtmlBlock
, or Page
The layout component
if_
optional
callable with context parameter
Only display the field if the function returns true. This one is the exact same one as presented in dynamic forms
component
required
"Row"
To enable this component
fields
required
Array of two fields
Allow to use multi pages forms. When using multi pages form, you must have only pages at the root of your form.
These two fields are the ones you want to display in a line
No layout elements are allowed in a Row
component; only fields