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

+12
View File
@@ -792,6 +792,18 @@ class FormBuilderTest extends PHPUnit\Framework\TestCase
$this->assertEquals('<textarea readonly name="test" cols="50" rows="10"></textarea>', $input);
}
public function testArrayClassAttributes()
{
$input = $this->formBuilder->text('test', null, ['class' => ['class-a', 'class-b']]);
$this->assertEquals('<input class="class-a class-b" name="test" type="text">', $input);
$input = $this->formBuilder->text('test', null, ['class' => [
'class-a',
false ? 'class-b' : 'class-c'
]]);
$this->assertEquals('<input class="class-a class-c" name="test" type="text">', $input);
}
protected function setModel(array $data, $object = true)
{
if ($object) {