src/FormHandler.php
protected function setRequiredFieldErrors($fields = null, $data = null)
    {
        if ($fields === null) {
            $fields =& $this->fields;
        }

        if ($data === null) {
            $data =& $this->data;
        }

        foreach ($fields as $field) {
            if (isset($field['options']['required']) && $field['options']['required'] === true) {
                if (!isset($data[ $field['name'] ]) || $data[ $field['name'] ] == null) {
                    if (isset($field['options']['label'])) {
                        $label = $field['options']['label'];
                    }
                    else {
                        $label = $field['name'];
                    }
                    $this->errors[] = new FormError($field['name'], "Field '{field_label}' must be set", true, array('field_label' => $label));
                }
            }

            if (isset($field['fields'])) {
                $this->setRequiredFieldErrors($field['fields'], $data[ $field['name'] ]);
            }
        }
    }
protected function setRequiredFieldErrors($fields = null, $data = null)
    {
        if ($fields === null) {
            $fields =& $this->fields;
        }

        if ($data === null) {
            $data =& $this->data;
        }

        foreach ($fields as $field) {
            if (isset($field['options']['required']) && $field['options']['required'] === true) {
                if (!isset($data[ $field['name'] ]) || $data[ $field['name'] ] == null) {
                    if (isset($field['options']['label'])) {
                        $label = $field['options']['label'];
                    }
                    else {
                        $label = $field['name'];
                    }
                    $this->errors[] = new FormError($field['name'], "Field '{field_label}' must be set", true, array('field_label' => $label));
                }
            }

            if (isset($field['fields'])) {
                $this->setRequiredFieldErrors($field['fields'], $data[ $field['name'] ]);
            }
        }
    }
protected function setRequiredFieldErrors ( $ fields = null , $ data = null ) { if ( $ fields === null ) { $ fields = & $ this -> fields ; } if ( $ data === null ) { $ data = & $ this -> data ; } foreach ( $ fields as $ field ) { if ( isset ( $ field [ 'options' ] [ 'required' ] ) && $ field [ 'options' ] [ 'required' ] === true ) { if ( ! isset ( $ data [ $ field [ 'name' ] ] ) || $ data [ $ field [ 'name' ] ] == null ) { if ( isset ( $ field [ 'options' ] [ 'label' ] ) ) { $ label = $ field [ 'options' ] [ 'label' ] ; } else { $ label = $ field [ 'name' ] ; } $ this -> errors [ ] = new FormError ( $ field [ 'name' ] , "Field '{field_label}' must be set" , true , array ( 'field_label' => $ label ) ) ; } } if ( isset ( $ field [ 'fields' ] ) ) { $ this -> setRequiredFieldErrors ( $ field [ 'fields' ] , $ data [ $ field [ 'name' ] ] ) ; } } }
Check each field to see if they're required. If they have no data set, assign the error
@param null $fields
@param null $data
Check each field to see if they re required . If they have no data set assign the error