Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Elements/Concerns/Groupable.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

/**
* @method \Galahad\Aire\Elements\Element label(string|Htmlable $text)
* @method \Galahad\Aire\Elements\Element helpText(string $text)
* @method \Galahad\Aire\Elements\Element helpText(string|Htmlable $text)
* @method \Galahad\Aire\Elements\Element validated($validation_state = 'valid')
* @method \Galahad\Aire\Elements\Element valid()
* @method \Galahad\Aire\Elements\Element invalid()
Expand Down
10 changes: 7 additions & 3 deletions src/Elements/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Galahad\Aire\Aire;
use Galahad\Aire\Contracts\NonInput;
use Illuminate\Contracts\Support\Htmlable;
use Illuminate\Support\HtmlString;

class Group extends Element implements NonInput
Expand Down Expand Up @@ -77,7 +78,7 @@ public function __construct(Aire $aire, Form $form, Element $element)
/**
* Set the group's label
*
* @param string|\Illuminate\Contracts\Support\Htmlable $text
* @param string|Htmlable $text
* @return \Galahad\Aire\Elements\Group
*/
public function label($text): self
Expand All @@ -99,8 +100,11 @@ public function variant($variant = null)

return parent::variant($variant);
}

public function helpText(string $text): self

/**
* @param string|Htmlable $text
*/
public function helpText($text): self
{
$this->view_data['help_text'] = $text;

Expand Down
11 changes: 11 additions & 0 deletions tests/Unit/GroupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Galahad\Aire\Tests\Unit;

use Galahad\Aire\Tests\TestCase;
use Illuminate\Support\HtmlString;
use Illuminate\Support\Str;

class GroupTest extends TestCase
Expand Down Expand Up @@ -64,6 +65,16 @@ public function test_a_group_can_have_help_text(): void

$this->assertSelectorTextEquals($input, 'div > small', 'Help text');
}

public function test_a_group_can_have_html_help_text(): void
{
$input = $this->aire()
->input()
->helpText(new HtmlString('Help <strong>text</strong>'))
->toHtml();

$this->assertSelectorTextEquals($input, 'div > small', 'Help text');
}

public function test_a_group_can_have_errors(): void
{
Expand Down