diff --git a/src/FormBuilder.php b/src/FormBuilder.php index a0cb439..1c7e22d 100644 --- a/src/FormBuilder.php +++ b/src/FormBuilder.php @@ -190,6 +190,16 @@ class FormBuilder { $this->model = $model; } + + /** + * Get the current model instance on the form builder. + * + * @return mixed $model + */ + public function getModel() + { + return $this->model; + } /** * Close the current form. @@ -729,7 +739,7 @@ class FormBuilder { $selected = $this->getSelectedValue($value, $selected); - $options = ['value' => $value, 'selected' => $selected] + $attributes; + $options = array_merge(['value' => $value, 'selected' => $selected], $attributes); $string = 'html->attributes($options) . '>'; if ($display !== null) { diff --git a/src/HtmlBuilder.php b/src/HtmlBuilder.php index a2e18f9..7eb37ae 100755 --- a/src/HtmlBuilder.php +++ b/src/HtmlBuilder.php @@ -94,7 +94,7 @@ class HtmlBuilder { $defaults = ['media' => 'all', 'type' => 'text/css', 'rel' => 'stylesheet']; - $attributes = $attributes + $defaults; + $attributes = array_merge($attributes, $defaults); $attributes['href'] = $this->url->asset($url, $secure); @@ -132,7 +132,7 @@ class HtmlBuilder { $defaults = ['rel' => 'shortcut icon', 'type' => 'image/x-icon']; - $attributes = $attributes + $defaults; + $attributes = array_merge($attributes, $defaults); $attributes['href'] = $this->url->asset($url, $secure); @@ -162,7 +162,7 @@ class HtmlBuilder $title = $this->entities($title); } - return $this->toHtmlString('attributes($attributes) . '>' . $title . ''); + return $this->toHtmlString('attributes($attributes) . '>' . $title . ''); } /** diff --git a/tests/HtmlBuilderTest.php b/tests/HtmlBuilderTest.php index a5bcb8b..3cb6029 100644 --- a/tests/HtmlBuilderTest.php +++ b/tests/HtmlBuilderTest.php @@ -118,8 +118,11 @@ class HtmlBuilderTest extends PHPUnit_Framework_TestCase $result2 = $this->htmlBuilder->link("http://www.example.com", "Example.com", ["class" => "example-link"], null, false); + $result3 = $this->htmlBuilder->link("https://a.com/b?id=4¬_id=5", "URL which needs escaping"); + $this->assertEquals('<span>Example.com</span>', $result1); $this->assertEquals('Example.com', $result2); + $this->assertEquals('URL which needs escaping', $result3); } public function testMailto()