uxf/form
最新稳定版本:3.79.0
Composer 安装命令:
composer require uxf/form
包简介
README 文档
README
Symfony Form bundle
Install
$ composer require uxf/form
Config
// config/routes/uxf.php
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
return static function (RoutingConfigurator $routingConfigurator): void {
$routingConfigurator->import('@UXFFormBundle/config/routes.php');
};
Service
// config/packages/uxf.php
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $config): void {
$config->extension('uxf_form', [
'gen' => [
'schema_with_hidden_fields' => true, // default false
'areas' => [
'admin' => [
'allowed' => '/^(admin|test)/', // optional
'disabled' => '/^(private|hello)/', // optional
'destination' => __DIR__ . '/../../../backoffice/src/generated/form-schema',
],
],
],
]);
};
Usage
OneToMany must have indexBy="id" and child entity must have property named $parent in constructor.
Events
FormEntityEditedEvent
use Symfony\Component\EventDispatcher\Attribute\AsEventListener;
use UXF\Core\Exception\BasicException;
use UXF\Form\Event\FormEntityEditedEvent;
#[AsEventListener]
final readonly class FormEntityEditedEventListener
{
public function __invoke(FormEntityEditedEvent $event): void
{
// do something with $event->entity and $event->new
}
}
FormEntityErrorEvent
use Symfony\Component\EventDispatcher\Attribute\AsEventListener;
use UXF\Core\Exception\BasicException;
use UXF\Form\Event\FormEntityErrorEvent;
#[AsEventListener]
final readonly class FormEntityErrorEventListener
{
public function __invoke(FormEntityErrorEvent $event): void
{
// custom exception
if ($event->entity instanceof Small && $event->error instanceof ORMException) {
$event->error = BasicException::badRequest('awesome');
}
}
}
统计信息
- 总下载量: 19.13k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-01-12