diff --git a/src/AireBootstrapServiceProvider.php b/src/AireBootstrapServiceProvider.php index 3f05098..0f7d9f3 100644 --- a/src/AireBootstrapServiceProvider.php +++ b/src/AireBootstrapServiceProvider.php @@ -14,6 +14,10 @@ public function boot() { $this->loadViewsFrom(dirname(__DIR__) . '/views', 'aire-bootstrap'); + $this->publishes([ + dirname(__DIR__).'/views' => $this->app->resourcePath('views/vendor/aire-bootstrap'), + ], 'aire-bootstrap-views'); + Aire::setTheme('aire-bootstrap', null, [ 'default_classes' => [ 'group' => 'form-group', @@ -21,7 +25,7 @@ public function boot() 'group_prepend' => 'input-group-prepend', 'group_append' => 'input-group-append', 'group_help_text' => 'form-text text-muted', - 'group_errors' => 'd-none', + 'group_errors' => '', 'label' => '', 'input' => 'form-control', @@ -137,9 +141,6 @@ public function boot() }); Input::registerElementMutator(function (Input $input) { - - // Apply a label by default - $input->group->label('Choose file'); $input->attributes->registerMutator('class', function (ClassNames $classNames) use ($input) { @@ -147,11 +148,11 @@ public function boot() $classNames ->remove('form-control') ->add('custom-file-input'); - + $input ->groupAddClass('custom-file') ->groupRemoveClass('form-group'); - + $input->group->label ->addClass('custom-file-label') ->removeClass('cursor-pointer'); diff --git a/tests/BootstrapMarkupTest.php b/tests/BootstrapMarkupTest.php index 4604a54..27c11c0 100644 --- a/tests/BootstrapMarkupTest.php +++ b/tests/BootstrapMarkupTest.php @@ -24,10 +24,10 @@ public function test_an_ungrouped_checkbox(): void ->id('foo-box') ->withoutGroup(); - $this->assertSelectorExists($html, 'div.form-check'); - $this->assertSelectorAttribute($html, 'div.form-check > input.form-check-input', 'name', 'demo'); - $this->assertSelectorAttribute($html, 'div.form-check > label.form-check-label', 'for', 'foo-box'); - $this->assertSelectorContainsText($html, 'div.form-check > label.form-check-label', 'Demo checkbox'); + $this->assertSelectorDoesNotExist($html,'.form-group'); + $this->assertSelectorAttribute($html, 'input.custom-control-input', 'name', 'demo'); + $this->assertSelectorAttribute($html, 'label.custom-control-label', 'for', 'foo-box'); + $this->assertSelectorContainsText($html, 'label.custom-control-label', 'Demo checkbox'); } public function test_a_select_form(): void @@ -61,7 +61,7 @@ public function test_submit_button_html() ->id('foo-submit-button'); $this->assertSelectorAttribute($html, 'button', 'type', 'submit'); - $this->assertSelectorAttribute($html, 'button', 'class', 'btn btn-primary'); + $this->assertSelectorAttribute($html, 'button', 'class', 'btn btn-primary '); $this->assertSelectorAttribute($html, 'button', 'id', 'foo-submit-button'); $this->assertSelectorContainsText($html, 'button', 'Submit Awesome'); } @@ -71,7 +71,17 @@ public function test_radio_group_form() : void $html = $this->aire()->form() ->radioGroup(['radio-1'=>'Radio 1','radio-2'=>'Radio 2'],'radio_selector','Foo Radio Selector'); - $this->assertSelectorAttribute($html, 'div.form-check > input.form-check-input', 'value', 'radio-1'); - $this->assertSelectorContainsText($html,'div.form-check > label.form-check-label','Radio 1'); + $this->assertSelectorContainsText($html, 'div.form-group > label', 'Foo Radio Selector'); + $this->assertSelectorAttribute($html,'div.custom-control.custom-radio > input.custom-control-input','value', 'radio-1'); + $this->assertSelectorAttribute($html,'div.custom-control.custom-radio + div.custom-control.custom-radio > input.custom-control-input','value', 'radio-2'); + } + + public function test_when_no_label_given_a_label_is_not_generated() : void + { + $html = $this->aire() + ->form() + ->input('text-input'); + + $this->assertSelectorDoesNotExist($html, 'label'); } }