diff --git a/Factory.php b/Factory.php index c0133ab..ebf16bf 100644 --- a/Factory.php +++ b/Factory.php @@ -75,11 +75,11 @@ protected function inject($object) /** * Get a parser */ - public function getParser($content, $offset = 0) + public function getParser($content, $offset = 0, $parser_parent = null) { $parserClass = $this->parserClass; - return $this->inject(new $parserClass($content, $this, $offset)); + return $this->inject(new $parserClass($content, $this, $offset, $parser_parent)); } /** diff --git a/Fields/MulticheckboxField.php b/Fields/MulticheckboxField.php index e8f26a5..9050f52 100644 --- a/Fields/MulticheckboxField.php +++ b/Fields/MulticheckboxField.php @@ -135,11 +135,12 @@ public function getHtml() $html = ''; if ($this->checkboxes) { - foreach ($this->checkboxes as $checkbox) { + + foreach ($this->checkboxes as $checkboxIndex=>$checkbox) { $html.= '
'; $html.= ''; $html.= '
'; } diff --git a/Fields/Multiple.php b/Fields/Multiple.php index 21873b9..8d42356 100644 --- a/Fields/Multiple.php +++ b/Fields/Multiple.php @@ -68,7 +68,7 @@ public function setValues($values, array $files) $this->forms = array(); $indexes = array(); - if ($values) { + if ($values && is_array($values)) { $indexes = array_keys($values); } else if ($files) { $indexes = array_keys($files); diff --git a/Parser.php b/Parser.php index c8dbefe..3647566 100644 --- a/Parser.php +++ b/Parser.php @@ -34,7 +34,20 @@ class Parser extends ParserData */ private $offset = 0; - public function __construct($content, $factory = null, $offset = 0) + /** + * Parent parser (for back references from multiples parsers) + */ + private $parser_parent; + + /** + * Parser constructor. + * @param $content + * @param null $factory + * @param int $offset + * @param null $parent + */ + + public function __construct($content, $factory = null, $offset = 0, $parser_parent = null) { if (null === $factory) { $this->factory = new Factory; @@ -42,6 +55,7 @@ public function __construct($content, $factory = null, $offset = 0) $this->factory = $factory; } + $this->parser_parent = $parser_parent; $this->offset = $offset; $this->parse($content); } @@ -135,7 +149,13 @@ private function parse($content) if (!$this->data[$idx-1] instanceof Fields\Select) { throw new ParserException('