src/Helpers/Form.php
protected function addValuesToFields(array $fields)
    {
        foreach ($fields as $name => &$field) {
            if (!empty($field['fields'])) {
                $field['fields'] = $this->addValuesToFields($field['fields']);
            } elseif ($field['type'] === 'checkbox') {
                // Value is a list of checked options.
                $value = array();
                foreach ($field['options'] as $optionName => $optionLabel) {
                    if ($this->getFormValue($optionName)) {
                        $value[] = $optionName;
                    }
                }
                $field['value'] = $value;
            } elseif (!isset($field['value'])) {
                // Explicitly set values (in the 'value' key) take precedence
                // over submitted values, which in turn take precedence over
                // default values (gathered via getDefaultFormValues()).
                $field['value'] = $this->getFormValue($name);
            }
        }
        return $fields;
    }
protected function addValuesToFields(array $fields)
    {
        foreach ($fields as $name => &$field) {
            if (!empty($field['fields'])) {
                $field['fields'] = $this->addValuesToFields($field['fields']);
            } elseif ($field['type'] === 'checkbox') {
                // Value is a list of checked options.
                $value = array();
                foreach ($field['options'] as $optionName => $optionLabel) {
                    if ($this->getFormValue($optionName)) {
                        $value[] = $optionName;
                    }
                }
                $field['value'] = $value;
            } elseif (!isset($field['value'])) {
                // Explicitly set values (in the 'value' key) take precedence
                // over submitted values, which in turn take precedence over
                // default values (gathered via getDefaultFormValues()).
                $field['value'] = $this->getFormValue($name);
            }
        }
        return $fields;
    }
protected function addValuesToFields ( array $ fields ) { foreach ( $ fields as $ name => & $ field ) { if ( ! empty ( $ field [ 'fields' ] ) ) { $ field [ 'fields' ] = $ this -> addValuesToFields ( $ field [ 'fields' ] ) ; } elseif ( $ field [ 'type' ] === 'checkbox' ) { // Value is a list of checked options. $ value = array ( ) ; foreach ( $ field [ 'options' ] as $ optionName => $ optionLabel ) { if ( $ this -> getFormValue ( $ optionName ) ) { $ value [ ] = $ optionName ; } } $ field [ 'value' ] = $ value ; } elseif ( ! isset ( $ field [ 'value' ] ) ) { // Explicitly set values (in the 'value' key) take precedence // over submitted values, which in turn take precedence over // default values (gathered via getDefaultFormValues()). $ field [ 'value' ] = $ this -> getFormValue ( $ name ) ; } } return $ fields ; }
Adds the form values to the field definitions.

This internal version of addValues() passes the fields as a parameter to
allow to recursively process field sets.

@param array[] $fields

@return array[]
Adds the form values to the field definitions .