protected function getFormFieldValuesFromModel(Model $model, array $keys)
    {
        $values = [];

        foreach ($keys as $key) {

            $field    = $this->getModelFormFieldDataForKey($key);
            $instance = $this->getFormFieldStoreStrategyInstanceForField($field);

            $instance->setFormFieldData($field);
            $instance->setParameters(
                $this->getFormFieldStoreStrategyParametersForField($field)
            );

            // If we're creating a new model, pre-select the form field for the active list parent
            if ( ! $model->exists && $this->isFieldValueBeDerivableFromListParent($field->key)) {

                try {
                    $values[ $key ] = $instance->valueForListParentKey($this->getListParentRecordKey());

                    // @codeCoverageIgnoreStart
                } catch (Exception $e) {
                    $message = "Failed retrieving value for form field '{$key}' (using " . get_class($instance)
                             . " (valueForListParentKey)): \n{$e->getMessage()}";

                    throw new StrategyRetrievalException($message, $e->getCode(), $e);
                    // @codeCoverageIgnoreEnd
                }

                continue;
            }

            try {
                $values[ $key ] = $instance->retrieve($model, $field->source ?: $field->key);

                // @codeCoverageIgnoreStart
            } catch (Exception $e) {
                $message = "Failed retrieving value for form field '{$key}' (using " . get_class($instance)
                         . "): \n{$e->getMessage()}";

                throw new StrategyRetrievalException($message, $e->getCode(), $e);
                // @codeCoverageIgnoreEnd
            }
        }

        return $values;
    }
protected function getFormFieldValuesFromModel(Model $model, array $keys)
    {
        $values = [];

        foreach ($keys as $key) {

            $field    = $this->getModelFormFieldDataForKey($key);
            $instance = $this->getFormFieldStoreStrategyInstanceForField($field);

            $instance->setFormFieldData($field);
            $instance->setParameters(
                $this->getFormFieldStoreStrategyParametersForField($field)
            );

            // If we're creating a new model, pre-select the form field for the active list parent
            if ( ! $model->exists && $this->isFieldValueBeDerivableFromListParent($field->key)) {

                try {
                    $values[ $key ] = $instance->valueForListParentKey($this->getListParentRecordKey());

                    // @codeCoverageIgnoreStart
                } catch (Exception $e) {
                    $message = "Failed retrieving value for form field '{$key}' (using " . get_class($instance)
                             . " (valueForListParentKey)): \n{$e->getMessage()}";

                    throw new StrategyRetrievalException($message, $e->getCode(), $e);
                    // @codeCoverageIgnoreEnd
                }

                continue;
            }

            try {
                $values[ $key ] = $instance->retrieve($model, $field->source ?: $field->key);

                // @codeCoverageIgnoreStart
            } catch (Exception $e) {
                $message = "Failed retrieving value for form field '{$key}' (using " . get_class($instance)
                         . "): \n{$e->getMessage()}";

                throw new StrategyRetrievalException($message, $e->getCode(), $e);
                // @codeCoverageIgnoreEnd
            }
        }

        return $values;
    }
protected function getFormFieldValuesFromModel ( Model $ model , array $ keys ) { $ values = [ ] ; foreach ( $ keys as $ key ) { $ field = $ this -> getModelFormFieldDataForKey ( $ key ) ; $ instance = $ this -> getFormFieldStoreStrategyInstanceForField ( $ field ) ; $ instance -> setFormFieldData ( $ field ) ; $ instance -> setParameters ( $ this -> getFormFieldStoreStrategyParametersForField ( $ field ) ) ; // If we're creating a new model, pre-select the form field for the active list parent if ( ! $ model -> exists && $ this -> isFieldValueBeDerivableFromListParent ( $ field -> key ) ) { try { $ values [ $ key ] = $ instance -> valueForListParentKey ( $ this -> getListParentRecordKey ( ) ) ; // @codeCoverageIgnoreStart } catch ( Exception $ e ) { $ message = "Failed retrieving value for form field '{$key}' (using " . get_class ( $ instance ) . " (valueForListParentKey)): \n{$e->getMessage()}" ; throw new StrategyRetrievalException ( $ message , $ e -> getCode ( ) , $ e ) ; // @codeCoverageIgnoreEnd } continue ; } try { $ values [ $ key ] = $ instance -> retrieve ( $ model , $ field -> source ? : $ field -> key ) ; // @codeCoverageIgnoreStart } catch ( Exception $ e ) { $ message = "Failed retrieving value for form field '{$key}' (using " . get_class ( $ instance ) . "): \n{$e->getMessage()}" ; throw new StrategyRetrievalException ( $ message , $ e -> getCode ( ) , $ e ) ; // @codeCoverageIgnoreEnd } } return $ values ; }
Collects and returns current values for fields by key from a model.

@param Model    $model
@param string[] $keys
@return array
@throws StrategyRetrievalException
Collects and returns current values for fields by key from a model .