uxf / form
3.80.3
2026-06-10 11:04 UTC
Requires
- php: ^8.4
- ext-json: *
- symfony/dependency-injection: ^7.4 || ^8.0
- uxf/core: 3.80.3
This package is auto-updated.
Last update: 2026-06-10 09:09:10 UTC
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');
}
}
}