Can set class attribute in array. (#521)

In case of you want to add class by condition.

```
Form::text('name', null, ['class' => [
    'form-control-,
    $error ? 'is-invalid' : '',
]]);
```
This commit is contained in:
ThunderbirdsX3 authored and Tom Shafer committed 2018-05-30 09:09:07 -07:00
1 parent 6d1ccebb53
commit fda9d3dad8
3 files changed
+30

No files matched your search

+14
View File
@@ -151,4 +151,18 @@ class HtmlBuilderTest extends PHPUnit\Framework\TestCase
$this->assertEquals('', trim($result2));
}
public function testArrayClassAttributes()
{
$result = $this->htmlBuilder->attributes(['class' => ['class-a', 'class-b']]);
$this->assertEquals('class="class-a class-b"', trim($result));
$result = $this->htmlBuilder->attributes(['class' => [
'class-a',
false ? 'class-b' : 'class-c'
]]);
$this->assertEquals('class="class-a class-c"', trim($result));
}
}