Skip to content

Commit

Permalink
Attempt to fix formCollection truncated content (issue #24)
Browse files Browse the repository at this point in the history
  • Loading branch information
neilime committed Nov 8, 2019
1 parent 29cb1b5 commit a84f359
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/TwbsHelper/Form/View/Helper/FormCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ class FormCollection extends \Zend\Form\View\Helper\FormCollection
{
use \TwbsHelper\View\Helper\HtmlTrait;

protected static $fieldsetRegex = '/(<fieldset[^>]*>)([\s\S]*)(<\/fieldset[^>]*>)$/imU';
protected static $legendRegex = '/<legend[^>]*>([\s\S]*)<\/legend[^>]*>/imU';

/**
* This is the default wrapper that the collection is wrapped into
*
Expand Down Expand Up @@ -36,7 +39,7 @@ public function render(\Zend\Form\ElementInterface $oElement): string
return $sMarkup;
}

if (!preg_match('/(<fieldset[^>]*>)([\s\S]*)(<\/fieldset[^>]*>)/imU', $sMarkup, $aMatches)) {
if (!preg_match(self::$fieldsetRegex, $sMarkup, $aMatches)) {
return $sMarkup;
}

Expand All @@ -54,7 +57,7 @@ public function render(\Zend\Form\ElementInterface $oElement): string

// Extract legend
$sLegendContent = '';
if (preg_match('/<legend[^>]*>([\s\S]*)<\/legend[^>]*>/imU', $sMarkup, $aLegendMatches)) {
if (preg_match(self::$legendRegex, $sMarkup, $aLegendMatches)) {
$sLegendContent = sprintf(
'<legend%s>%s</legend>',
$this->attributesToString($this->setClassesToAttributes(
Expand Down

0 comments on commit a84f359

Please sign in to comment.