Skip to content

Commit

Permalink
Add form fields styling config
Browse files Browse the repository at this point in the history
  • Loading branch information
Mister-42 committed Dec 23, 2020
1 parent a08e951 commit 03413c6
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 9 deletions.
10 changes: 3 additions & 7 deletions composer.json
Expand Up @@ -50,13 +50,9 @@
"branch-alias": {
"dev-master": "1.0.x-dev"
},
"installer-types": [
"npm-asset"
],
"installer-paths": {
"./node_modules/{$name}": [
"type:npm-asset"
]
"config-plugin": {
"params": "config/params.php",
"web": "config/web/*.php"
}
},
"config": {
Expand Down
18 changes: 18 additions & 0 deletions config/params.php
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

return [
'yiisoft/form' => [
'bulma' => [
'enabled' => true,
'fieldConfig' => [
'inputCssClass()' => ['input field mb-1'],
'labelOptions()' => [['label' => '']],
'errorOptions()' => [['class' => 'help is-danger has-text-left is-italic mt-0 mb-2']],
'errorCssClass()' => ['is-danger'],
'successCssClass()' => ['is-success'],
],
],
],
];
11 changes: 11 additions & 0 deletions config/web/field.php
@@ -0,0 +1,11 @@
<?php

declare(strict_types=1);

use Yiisoft\Form\Widget\Field;

if ($params['yiisoft/form']['bulma']['enabled'] === true) {
return [
Field::class => fn () => Field::Widget($params['yiisoft/form']['bulma']['fieldConfig']),
];
}
5 changes: 3 additions & 2 deletions tests/TestCase.php
Expand Up @@ -39,7 +39,8 @@ protected function setUp(): void
/* Set aliases tests */
$this->aliases->set('@assets', __DIR__ . '/data');
$this->aliases->set('@assetsUrl', '/');
$this->aliases->set('@npm', dirname(__DIR__) . '/node_modules');
$this->aliases->set('@vendor', dirname(__DIR__) . '/vendor');
$this->aliases->set('@npm', '@vendor/npm-asset');

$this->assetManager = $this->container->get(AssetManager::class);
}
Expand Down Expand Up @@ -115,7 +116,7 @@ private function config(): array
],

AssetManager::class => static function (ContainerInterface $container) {
$assetManager = new AssetManager($container->get(LoggerInterface::class));
$assetManager = new AssetManager($container->get(Aliases::class));

$assetManager->setConverter($container->get(AssetConverterInterface::class));
$assetManager->setPublisher($container->get(AssetPublisherInterface::class));
Expand Down

0 comments on commit 03413c6

Please sign in to comment.