APF_Demo_AdvancedUsage_Verification_Section::replyToValidateSection PHP Method

replyToValidateSection() public method

Validates the 'section_verification' section items.
public replyToValidateSection ( $aInput, $aOldInput, $oAdminPage, $aSubmitInfo )
    public function replyToValidateSection($aInput, $aOldInput, $oAdminPage, $aSubmitInfo)
    {
        // Local variables
        $_bIsValid = true;
        $_aErrors = array();
        if ('0' === (string) $aInput['item_a'] && '' === trim($aInput['item_b'])) {
            $_bIsValid = false;
            $_aErrors['section_verification'] = __('At least one item must be set', 'admin-page-framework-loader');
        }
        if (!$_bIsValid) {
            $oAdminPage->setFieldErrors($_aErrors);
            $oAdminPage->setSettingNotice(__('There was an error setting an option in a form section.', 'admin-page-framework-loader'));
            return $aOldInput;
        }
        // Otherwise, process the data.
        return $aInput;
    }
APF_Demo_AdvancedUsage_Verification_Section