wip: initial commit
This commit is contained in:
1 parent
ae964198e9
commit
d4c4e69d09
91 files changed
+32685
-144
No files matched your search
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form\Extension;
|
||||
|
||||
use Symfony\Component\Form\AbstractTypeExtension;
|
||||
use Symfony\Component\Form\Extension\Core\Type\FormType;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\Form\FormView;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class HtmxSubmitExtension extends AbstractTypeExtension
|
||||
{
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'hx_post' => null,
|
||||
'hx_target' => '#htmx-modal',
|
||||
'hx_swap' => 'outerHTML',
|
||||
'hx_indicator' => '#loading-indicator',
|
||||
'hx_trigger' => null,
|
||||
'hx_select' => null,
|
||||
]);
|
||||
}
|
||||
|
||||
public function buildView(FormView $view, FormInterface $form, array $options): void
|
||||
{
|
||||
if (null !== $options['hx_post']) {
|
||||
$attr = [
|
||||
'hx-post' => $options['hx_post'],
|
||||
'hx-target' => $options['hx_target'],
|
||||
'hx-swap' => $options['hx_swap'],
|
||||
];
|
||||
if (null !== $options['hx_indicator']) {
|
||||
$attr['hx-indicator'] = $options['hx_indicator'];
|
||||
}
|
||||
if (null !== $options['hx_trigger']) {
|
||||
$attr['hx-trigger'] = $options['hx_trigger'];
|
||||
}
|
||||
if (null !== $options['hx_select']) {
|
||||
$attr['hx-select'] = $options['hx_select'];
|
||||
}
|
||||
$view->vars['attr'] = array_merge($view->vars['attr'], $attr);
|
||||
}
|
||||
}
|
||||
|
||||
public static function getExtendedTypes(): iterable
|
||||
{
|
||||
return [FormType::class];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user