Skip to content
Permalink
Browse files

declare instance variable, add docblocks

  • Loading branch information...
Jonas Hartmann
Jonas Hartmann committed Jul 17, 2016
1 parent 48bd343 commit b37f5311b0444c8f0c2c964609cc54de0fb7cec8
Showing with 30 additions and 1 deletion.
  1. +30 −1 src/View/Helper/FormHelper.php
@@ -205,6 +205,13 @@ class FormHelper extends Helper
*/
protected $_lastAction = '';
/**
* The values sources to be used to retrieve prefilled input values from.
*
* @var array
*/
protected $_valuesSources = [];
/**
* Construct the widgets and binds the default context providers
*
@@ -359,7 +366,7 @@ public function create($model = null, array $options = [])
'encoding' => strtolower(Configure::read('App.encoding')),
'templates' => null,
'idPrefix' => null,
'valuesSources' => [],
'valuesSources' => 'context',
];
if (isset($options['action'])) {
@@ -2676,18 +2683,40 @@ public function implementedEvents()
return [];
}
/**
* Gets the value sources.
*
* Returns a list, but at least one item, of valid sources, such as: `'context'`, `'data'` and `'query'`.
*
* @return array List of value sources.
*/
public function getValuesSources()
{
return $this->_valuesSources;
}
/**
* Sets the value sources.
*
* Valid values are `'context'`, `'data'` and `'query'`.
* You need to supply one valid context or multiple, as a list of strings. Order sets priority.
*
* @param string|array $sources A string or a list of strings identifying a source.
* @return $this
*/
public function setValuesSources($sources)
{
$this->_valuesSources = array_values(array_intersect((array)$sources, ['context', 'data', 'query']));
return $this;
}
/**
* Gets a single field value from the sources available.
*
* @param string $fieldname The fieldname to fetch the value for.
* @return string Field value derived from sources.
*/
public function getSourceValue($fieldname)
{
foreach ($this->getValuesSources() as $valuesSource) {

0 comments on commit b37f531

Please sign in to comment.
You can’t perform that action at this time.