2.7 Creating Your First List View
Last updated
Was this helpful?
Last updated
Was this helpful?
Now that you understand how to add elements and implement validation in your pages, let's explore how to create your first list view in BetterForms. This guide will walk you through the process of setting up and managing a list of rows in your application.
A list view in BetterForms is a dynamic way to display and manage multiple rows of data. Each row can consist of various fields, allowing you to create complex forms that handle multiple entries, such as address lists or contact details.
Note: For more advanced table-based data display with features like sorting, filtering, and pagination, see .
List views are ideal for:
Simple multi-row data entry forms
Contact lists or address books
Product lists with basic information
Any scenario where you need to add/remove rows of similar data
For more complex data display needs (sorting, filtering, pagination), consider using instead.
listrows
ComponentThe listrows
component is used to display and manage a list of rows where each row consists of fields defined in the schema. This allows for the dynamic rendering of forms that include multiple rows of data inputs.
Here's an example of how to configure a listrows
component:
model
: The data model path where the array of rows is stored. In this case, address
is the model where each row of contact data is kept.
min
: Defines the minimum number of rows required (e.g., 2).
max
: Defines the maximum number of rows allowed (e.g., 4).
schema.fields
: An array of field configurations that will be displayed in each row. Each field can have its label, model, input type, and layout styling.
Each row contains four text input fields
The [+][-] buttons allow adding/removing rows
The component enforces a minimum of 2 and maximum of 4 rows
Set Appropriate Limits: Always define min
and max
values to prevent users from creating too many or too few rows.
Use Consistent Styling: Apply consistent styleClasses
to maintain a clean layout.
Validate Each Field: Consider adding validation rules to individual fields within the rows.
Consider Mobile Layout: Use responsive classes (like col-md-3
) to ensure the form looks good on all devices.
The listrows
component is versatile and can handle different types of input fields like text, checkboxes, and dropdowns.
The display of Add and Delete icons is automatically handled based on the defined min
and max
values.
Each row's data is stored as an object in the array specified by the model
attribute.
You now have a basic understanding of how to create a list view in BetterForms. As you build out your first application, you'll become more familiar with these components and how to use them effectively.
For more advanced data display needs, you can explore:
for complex table-based data display
for all available components