validateAdminBox()public function validateAdminBox($path, $settingGroup, &$box, &$fields, &$values, $changes, $saving) { //...your PHP code...// }
Use this method to write validation for your Admin Boxes.
This method will be called when an administrator changes tab in your Admin Box, or hits the "Save" button.
From Zenario 7.0.0 onwards.
You should use this method to validate all of the fields in your Admin Box.
Firstly you should check if each tab is in edit-mode. If a tab is not being edited (e.g. it might be in view or read-only mode), then it should not be validated.
Secondly you should populate the errors property for each tab with errors if there are any problems. (If an error relates to a field, you may put the error in the error property of the field instead.)
Your Admin Boxes will only be saved if they are free of errors!
$pathThe path of the Admin Box opened.
$settingGroupWhen showing an Admin Box for Plugin Settings or Site Settings, this variable will contain the name of the Module or Settings Group.
$boxThe TUIX that defines your Admin Box, in the form of a PHP array.
You should make changes to this array as needed.
$fieldsShortcuts to the field definitions in your Admin Box.
E.g. $fields['tab_name/field_name'] references $box['tabs']['tab_name']['fields']['field_name']
$valuesShortcuts to the field values in your Admin Box.
E.g. $values['tab_name/field_name'] references $box['tabs']['tab_name']['fields']['field_name']['current_value']
$changesThis parameter currently deprecated and should not be used. In the future it may be replaced by something more useful.
$savingThis will be set to true if the Admin is trying to save the Admin Box, and to false if the Admin is just trying to navigate to a different tab.
You may find that it's friendlier if certain errors are only shown when an administrator tries to save.
No return value is needed.