Skip to content

Commit

Permalink
Fix bug related to indexing fields when there's fieldsets
Browse files Browse the repository at this point in the history
  • Loading branch information
dvlpp committed Feb 12, 2016
1 parent ba71344 commit 615f230
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/Dvlpp/Sharp/Config/Utils/HasFormTemplateTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,19 @@ trait HasFormTemplateTrait
*/
public function addField($name, $update=true, $creation=true)
{
$this->fields[] = $name;

end($this->fields);
$lastKey = key($this->fields);

if($update) {
$this->updateIndexes[] = sizeof($this->fields);
$this->updateIndexes[] = $lastKey;
}

if($creation) {
$this->createIndexes[] = sizeof($this->fields);
$this->createIndexes[] = $lastKey;
}

$this->fields[] = $name;

return $this;
}

Expand Down Expand Up @@ -90,6 +93,7 @@ public function fields($mode)
$fields[$key] = $item;
}
}

return $fields;

// PHP 5.6: we can use ARRAY_FILTER_USE_BOTH
Expand Down

0 comments on commit 615f230

Please sign in to comment.