Add hypothetical loading of data

This commit is contained in:
Samuel Georges 2015-03-04 19:13:15 +11:00
parent 25d4c11f3f
commit be2e40e69f
1 changed files with 10 additions and 1 deletions

View File

@ -80,7 +80,12 @@ class Repeater extends FormWidgetBase
protected function processExistingItems()
{
$itemIndexes = post(self::INDEX_PREFIX.$this->formField->getName(false), array_keys($this->getLoadValue()));
$loadValue = $this->getLoadValue();
if (is_array($loadValue)) {
$loadValue = array_keys($loadValue);
}
$itemIndexes = post(self::INDEX_PREFIX.$this->formField->getName(false), $loadValue);
if (!is_array($itemIndexes)) return;
@ -92,8 +97,12 @@ class Repeater extends FormWidgetBase
protected function makeFormWidget($index = 0)
{
$loadValue = $this->getLoadValue();
if (!is_array($loadValue)) $loadValue = [];
$config = $this->makeConfig($this->form);
$config->model = $this->model;
$config->data = array_get($loadValue, $index);
$config->alias = $this->alias . 'Form'.$index;
$config->arrayName = $this->formField->getName().'['.$index.']';