src/Helpers/Form.php
protected function setFormValues()
    {
        if (!$this->formValuesSet) {
            // Start by assuring the field definitions are constructed.
            $this->getFields();

            // 1: Hard coded default value for form fields: empty string.
            $this->formValues = array_fill_keys($this->getKeys(), '');

            // 2: Overwrite with the default values from the field definitions,
            // but do so with some special array handling.
            $defaultFormValues = $this->getDefaultFormValues();
            foreach ($defaultFormValues as $key => $defaultFormValue) {
                // We start with a simple overwrite.
                if (array_key_exists($key, $this->formValues)) {
                    $this->formValues[$key] = $defaultFormValue;
                } elseif (is_array($defaultFormValue)) {
                // Distribute keyed arrays over separate values if existing.
                    foreach ($defaultFormValue as $arrayKey => $arrayValue) {
                        $fullKey = "{$key}[{$arrayKey}]";
                        if (array_key_exists($fullKey, $this->formValues)) {
                            $this->formValues[$fullKey] = $arrayValue;
                        }
                    }
                }
            }

            // 3: Overwrite with the submitted values.
            if (!empty($this->submittedValues)) {
                $this->formValues = array_merge($this->formValues, $this->submittedValues);
            }

            // 4: Overwrite with the (hard set) values as set in the field
            // definitions.
            $this->formValues = array_merge($this->formValues, $this->getFieldValues($this->getFields()));

            // 5: Allow for any web shop specific processing of the values.
            // Known usages:
            // - Prepend (checked) checkboxes with their collection name
            //   (PrestaShop).
            // - Place (checked) checkboxes in their collection (Magento).
            $this->formValues = $this->formHelper->alterFormValues($this->formValues);

            $this->formValuesSet = true;
        }
    }
protected function setFormValues()
    {
        if (!$this->formValuesSet) {
            // Start by assuring the field definitions are constructed.
            $this->getFields();

            // 1: Hard coded default value for form fields: empty string.
            $this->formValues = array_fill_keys($this->getKeys(), '');

            // 2: Overwrite with the default values from the field definitions,
            // but do so with some special array handling.
            $defaultFormValues = $this->getDefaultFormValues();
            foreach ($defaultFormValues as $key => $defaultFormValue) {
                // We start with a simple overwrite.
                if (array_key_exists($key, $this->formValues)) {
                    $this->formValues[$key] = $defaultFormValue;
                } elseif (is_array($defaultFormValue)) {
                // Distribute keyed arrays over separate values if existing.
                    foreach ($defaultFormValue as $arrayKey => $arrayValue) {
                        $fullKey = "{$key}[{$arrayKey}]";
                        if (array_key_exists($fullKey, $this->formValues)) {
                            $this->formValues[$fullKey] = $arrayValue;
                        }
                    }
                }
            }

            // 3: Overwrite with the submitted values.
            if (!empty($this->submittedValues)) {
                $this->formValues = array_merge($this->formValues, $this->submittedValues);
            }

            // 4: Overwrite with the (hard set) values as set in the field
            // definitions.
            $this->formValues = array_merge($this->formValues, $this->getFieldValues($this->getFields()));

            // 5: Allow for any web shop specific processing of the values.
            // Known usages:
            // - Prepend (checked) checkboxes with their collection name
            //   (PrestaShop).
            // - Place (checked) checkboxes in their collection (Magento).
            $this->formValues = $this->formHelper->alterFormValues($this->formValues);

            $this->formValuesSet = true;
        }
    }
protected function setFormValues ( ) { if ( ! $ this -> formValuesSet ) { // Start by assuring the field definitions are constructed. $ this -> getFields ( ) ; // 1: Hard coded default value for form fields: empty string. $ this -> formValues = array_fill_keys ( $ this -> getKeys ( ) , '' ) ; // 2: Overwrite with the default values from the field definitions, // but do so with some special array handling. $ defaultFormValues = $ this -> getDefaultFormValues ( ) ; foreach ( $ defaultFormValues as $ key => $ defaultFormValue ) { // We start with a simple overwrite. if ( array_key_exists ( $ key , $ this -> formValues ) ) { $ this -> formValues [ $ key ] = $ defaultFormValue ; } elseif ( is_array ( $ defaultFormValue ) ) { // Distribute keyed arrays over separate values if existing. foreach ( $ defaultFormValue as $ arrayKey => $ arrayValue ) { $ fullKey = "{$key}[{$arrayKey}]" ; if ( array_key_exists ( $ fullKey , $ this -> formValues ) ) { $ this -> formValues [ $ fullKey ] = $ arrayValue ; } } } } // 3: Overwrite with the submitted values. if ( ! empty ( $ this -> submittedValues ) ) { $ this -> formValues = array_merge ( $ this -> formValues , $ this -> submittedValues ) ; } // 4: Overwrite with the (hard set) values as set in the field // definitions. $ this -> formValues = array_merge ( $ this -> formValues , $ this -> getFieldValues ( $ this -> getFields ( ) ) ) ; // 5: Allow for any web shop specific processing of the values. // Known usages: // - Prepend (checked) checkboxes with their collection name //   (PrestaShop). // - Place (checked) checkboxes in their collection (Magento). $ this -> formValues = $ this -> formHelper -> alterFormValues ( $ this -> formValues ) ; $ this -> formValuesSet = true ; } }
Sets the form values to use.

This is typically the union of the default values, any submitted values,
and explicitly set field values.
Sets the form values to use .