budibase
budibase copied to clipboard
Form block
Description
Finishing off an old lab day! This PR adds a form block. The form block is a fully functional form complete with fields, a title and optional save and delete buttons. Form blocks only work with plus datasources; internal tables and SQL tables. Becuase of this, they are pretty much zero config. Just pick your table and pick your fields, and the save and delete buttons will just work.
Form blocks support being ejected. This PR is currently targeting the block ejection branch but this will be updated to develop whenever that gets merged.
Settings
Form block settings are very simple, as they are designed to be as easy to use as possible:
Form blocks have 3 distinct types - create, update and view. This is the first setting of the form block:
The type of the form block controls multiple behaviours, so it's important to pick the right one.
-
Create: for creating new data. Fields do not inherit values, and you do not have a "row ID" setting to update. You can have a "Save" button but you cannot have a "Delete" button.
-
Update: for updating existing data. Fields are prefilled with the existing values. You get an additional setting for "Row ID", which is the ID of the row you want to update (usually pulled from URL, but does not have to be). You can have a "Save" button and a "Delete" button.
-
View: for viewing existing data in a form. Fields are prefilled with the existing values, and are disabled. You cannot edit data, and you cannot have any buttons. This is for displaying data only.
General settings
- Type (required): the type of form, described above
- Table (required): the table you're creating/updating/viewing data in. Only tables are displayed here (no custom queries), making it very clear that it only works with plus datasources
- Title (optional): the form title, displayed above the form
- Size (required): the size of everthing in the form, defaulted to medium
If you pick an update or view form, you get one additional required setting, which is the row ID you want to update/display:
Field settings
The field settings are very simple.
- Fields (required): a multi select picker of which fields you would like to have in your form. All field types are supported.
- Field labels (required): the position of field labels, either to the left or above your fields. Defaults to left.
- Disabled (optional): you can optionally disable all fields with this setting
Button settings
The button settings available depend on the type of the form block. Update forms have the most, with both saveand delete buttons allowed. Create forms only have a checkbox for a save button, and view forms have no button settings at all, so this section will not appear.
The "Navigate after button press" is an optional setting to navigate to a different screen after saving or deleting a row. If your screen is rendered inside a modal (e.g. if you're using a form block on a details screen, and you came here from a list screen and are inside a modal) then pressing either button automatically closes the screen modal, so you can just ignore this setting.
Other stuff
- As this is the most complicated block so far, some new functionality was required. New features are in place to allow blocks providing bindings to themselves (seen here as you can use data about the row to fill in the title of the form, for example).#
- Component setting rendering improved (empty sections will not be shown at all)
- Schema generation made consistent between client library and builder, finally