From a90dbdbc48306dc267d848bb0b7381cbee7ffbdc Mon Sep 17 00:00:00 2001 From: Stephen Wolff Date: Tue, 14 May 2019 16:48:26 +0100 Subject: [PATCH 1/3] Fix issue with checkbox, where 0 coerced to nothing causing index to fail --- Fields/MulticheckboxField.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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.= '
'; } From be3037aa111d195f355fe3d54ab4f2beed98b236 Mon Sep 17 00:00:00 2001 From: Stephen Wolff Date: Wed, 15 May 2019 09:49:23 +0100 Subject: [PATCH 2/3] Create source entry in parent parser source array, to enable sources in multiple subforms --- Factory.php | 4 ++-- Parser.php | 28 +++++++++++++++++++++++++--- 2 files changed, 27 insertions(+), 5 deletions(-) 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/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('