// src/EventListener/OptionsEventListener.php
use HeimrichHannot\FormTypeBundle\Event\FieldOptionsEvent;
class OptionsEventListener implements EventSubscriberInterface
{
public static function getSubscribedEvents()
{
return [
'huh.form_type.huh_media_library.licence.options' => 'onLicenceOptions',
];
}
public function onLicenceOptions(FieldOptionsEvent $event): void
{
$event->addOption('free', 'Free');
$event->addOption('adobe', 'Adobe');
$event->addOption('istock', 'iStock');
}
}
use HeimrichHannot\MediaLibraryBundle\Trait\FieldOptionsDispatcherTrait;
class MyContainerOrFormType
{
use FieldOptionsDispatcherTrait;
#[AsCallback(table: 'tl_ml_product', target: 'fields.licence.options')]
#[AsEventListener('huh.form_type.huh_media_library.licence.options')]
public function getLicenceOptions(): array
{
return $this->dispatchFieldOptions([
'free' => 'Released for use under indication of copyright',
'locked' => 'Subject to licence'
]);
}
}
use HeimrichHannot\FormTypeBundle\FormType\FormContext;
use HeimrichHannot\FormTypeBundle\FormType\FormContextAction;
$formContext = new FormContext(FormContextAction::UPDATE, 'tl_my_table', $data);
use HeimrichHannot\FormTypeBundle\FormType\FormContext;
use HeimrichHannot\FormTypeBundle\FormType\FormContextAction;
$formContext = new FormContext('my_custom_action', 'tl_my_table', $data);
// or
$formContext->setAction('this_can_be_any_string_or_action');
// or
$formContext->setAction(FormContextAction::DELETE);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.