Form
1. Overview
In Mitra, forms can be created from the tables built in the database. These forms can be used to add or edit records and can be linked to various interface components such as buttons, tables, or lists, enabling dynamic and automated interactions.
2. How to Create a Form
Navigate to the "Interfaces" screen in Mitra.
Click the "New" button to start creating a new form.
Select the table the form will be linked to. This will define the data source for the form, enabling you to add, edit, or view records associated with that table.
3. IDs and Description
Every table created in Mitra includes two native attributes: ID and Description.
ID: Can be auto-incremental, numeric, or text. If the ID is auto-incremental, it will also behave as such in the form, meaning the user will not need to interact with it, as it will be generated automatically. If not auto-incremental, it will appear in the form for user input.
Description: This is a native attribute that appears in the form by default. Users can rename the "Description" field or, if they do not wish to use it, mark the description as auto-incremental, which effectively bypasses it during data entry.
4. Foreign Key (FK) Fields
FK fields offer several configuration options for managing related data:
Fixed: Use this option when you want a field to always have the same value. Example: When creating a task, the task status can automatically be set to "pending" without user selection.
Selection: Ideal when a form needs to retrieve a value based on the screen's context. For example, when clicking on a deal in a list, you can open an "item" form where the "deal" field is pre-filled with the selected deal.
Lookup: Allows users to select values from a dropdown, such as populating a "City" field for a salesperson from a list of cities.
Lookup and Add: Enables users to both select an existing value and add a new one during data entry. For instance, while registering a salesperson, if the desired city is not listed, the user can add it on the spot.
5. Common Attributes (Text, Number, Date)
For common fields such as text, number, and date, the following configurations control their behavior:
Editable: The field can be filled or modified by the user.
Locked: The field will be visible but cannot be edited.
Required: The field must be filled out.
Hidden: The field will not appear in the form.
6. Attachments
If you need to attach files like photos or documents to the form, use a text attribute and check the "Attachment" option. For example, while registering a salesperson, you can create a "photo" field, mark it as an attachment, and upload a photo via the form. The image (photo_of_jose.jpg) will be uploaded to Mitra Drive, and the link will be stored in the salesperson’s record.
7. Masks
Text and number fields can have masks applied to ensure the data follows predefined formats, such as CPF, CNPJ, ZIP codes, phone numbers, or time.
8. Numeric Attributes
Numeric fields have specific configurations:
Prefix and Suffix: Add characters before (prefix) or after (suffix) the numeric value.
Allow Duplicates: In cases where unique values are required (CNPJ), deselect this option to ensure no duplicates are stored in the database. For instance, if two records cannot share the same CNPJ, the form will automatically validate this.
9. Reordering Fields
The order of fields in the form can be easily adjusted by dragging them within the configuration interface. This allows you to customize the layout as needed.
10. Advanced Settings
Public Form: You can generate a public link to access the form without requiring login credentials.
Post-Submission Message: Configure a confirmation message for the user after submitting the form.
Post-Addition/Editing Action: Automate actions triggered after form submission. Example: After creating a project, you can set up an action to automatically generate tasks.
11. Using the Form Without Actions
When using the form component, it is not necessary to configure actions or database actions for inserting or editing records. The form automatically performs these operations:
Add Records: The form directly inserts the data into the associated table without requiring any extra actions.
Edit Records: Similarly, when using a form to edit records, there is no need to configure an "UPDATE" action in the database. The form automatically edits the records without requiring any additional actions.
12. Interaction with SQL Views
When using an edit form within an SQL view, ensure the ID field is correctly mapped. Mitra needs to recognize which table the ID corresponds to for the form to function properly. For example, if you are using a customer view, you must map the customer ID column to the corresponding table.