Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
### Added - new FormBuilder element: FormButton
- Loading branch information
Alexandr Fanamurov
committed
Mar 26, 2018
1 parent
a6572a7
commit 9cf5ab3
Showing
4 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace Larrock\Core\Helpers\FormBuilder; | ||
|
||
class FormButton extends FBElement | ||
{ | ||
/** @var string Тип кнопки (submit|button|reset) */ | ||
public $buttonType = 'submit'; | ||
|
||
/** @var string Имя шаблона FormBuilder для отрисовки поля */ | ||
public $FBTemplate = 'larrock::admin.formbuilder.button.button'; | ||
|
||
/** | ||
* Указываем тип кнопки (submit|button|reset) | ||
* @param $buttonType | ||
* @return $this | ||
*/ | ||
public function setButtonType($buttonType) | ||
{ | ||
$this->buttonType = $buttonType; | ||
return $this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace Larrock\Core\Tests\Helpers\FormBuilder; | ||
|
||
use Larrock\Core\Helpers\FormBuilder\FormButton; | ||
use Larrock\Core\LarrockCoreServiceProvider; | ||
|
||
class FormButtonTest extends \Orchestra\Testbench\TestCase | ||
{ | ||
/** @var FormButton */ | ||
protected $FormButton; | ||
|
||
protected function setUp() | ||
{ | ||
parent::setUp(); | ||
|
||
$this->FormButton = new FormButton('test_name', 'test_title'); | ||
} | ||
|
||
public function tearDown() | ||
{ | ||
parent::tearDown(); | ||
|
||
unset($this->FormButton); | ||
} | ||
|
||
protected function getPackageProviders($app) | ||
{ | ||
return [ | ||
LarrockCoreServiceProvider::class | ||
]; | ||
} | ||
|
||
public function testSetTypo() | ||
{ | ||
$this->FormButton->setButtonType('button'); | ||
$this->assertEquals('button', $this->FormButton->buttonType); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<div class="uk-form-row form-group-{{ $row_key }} {{ $row_settings->cssClassGroup }}"> | ||
<button type="{{ $row_settings->buttonType or 'button' }}" name="{{ $row_key }}" | ||
class="uk-button {{ $row_settings->cssClass }}" id="{{ $row_key }}">{{ $row_settings->title }}</button> | ||
@if($row_settings->help) | ||
<span class="uk-label uk-label-warning">({{ $row_settings->help }})</span> | ||
@endif | ||
</div> |