Admin Boxes Method validateAdminBox()

public function validateAdminBox(
$path, $settingGroup, &$box, &$fields, &$values, $changes, $saving
) { //...your PHP code...// }

Summary

Use this method to write validation for your Admin Boxes.

Context

This method will be called when an administrator changes tab in your Admin Box, or hits the "Save" button.

Where You Can Use It

From Zenario 7.0.0 onwards.

Description

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!

Parameters

$path

The path of the Admin Box opened.

$settingGroup

When showing an Admin Box for Plugin Settings or Site Settings, this variable will contain the name of the Module or Settings Group.

$box

The TUIX that defines your Admin Box, in the form of a PHP array.

You should make changes to this array as needed.

$fields

Shortcuts to the field definitions in your Admin Box.

E.g. $fields['tab_name/field_name'] references $box['tabs']['tab_name']['fields']['field_name']

$values

Shortcuts 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']

$changes

This parameter currently deprecated and should not be used. In the future it may be replaced by something more useful.

$saving

This 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.

Return Value

No return value is needed.