SuiteCRM 8.2 | Required field on secondary tab not being validated

I have a module with multiple tabs, and on the second tab, there is a required field.

The system allows us to create a record without ever filling the required field. All we have to do is never going into the second tab, and saving the record.

Pre-requisites:

  • SuiteCRM version 8.2
  • Module with multiple tabs
  • Required field on a secondary tab

Steps to reproduce

  • Click on create new record, a form will appear
  • Fill the fields on the first tab, don’t go onto the second tab
  • Click the save button, a new record will be created

Result
A new record would be created

Expected Result
An error when trying to save, saying that those required fields are empty.

I think even I observed this behavior in the v7.13.x.

I must be bug and you could check on GitHub to find it.

Custom Validation Logic:
1.Override Save Logic:
Identify the file responsible for saving records in your module. It could be something like modules/Your_Module/Save.php.
2.Check Required Fields:
In the save logic, before saving the record, check if the required fields on the second tab have values.
3. Display Error Message:
If the required fields are empty, prevent the save operation and display an error message.
Example:
// In your Save.php file
// Assuming $bean is your current record being saved
if (empty($bean->field_on_second_tab)) {
$error_message = “Required field on the second tab is empty. Please fill it.”;
$GLOBALS[‘log’]->fatal($error_message);
// Display an error message to the user $app->error_handler->display_error($error_message);
// Prevent saving the record
sugar_cleanup(true);
}