How to customize DateRangeFilterType theme #233
-
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
@Kreyu can you help me with this issue? It seems that is related with a form theme block, but I can't see which one... Which is the underlying form type used for data ranges? And its Twig block prefix? |
Beta Was this translation helpful? Give feedback.
-
It's called data-table-bundle/src/Resources/views/themes/bootstrap_5.html.twig Lines 980 to 986 in 2df63d0 |
Beta Was this translation helpful? Give feedback.
-
thank you so much @maciazek ! |
Beta Was this translation helpful? Give feedback.
-
Finally I need to apply a custom placeholder text into each field ( namespace Kreyu\Bundle\DataTableBundle\Filter\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\DataMapperInterface;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\FormBuilderInterface;
class DateRangeType extends AbstractType implements DataMapperInterface
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('from', DateType::class, [
'widget' => 'single_text',
'label' => false,
'attr' => [
'autocomplete' => 'off',
],
])
->add('to', DateType::class, [
'widget' => 'single_text',
'label' => false,
'attr' => [
'autocomplete' => 'off',
],
])
->setDataMapper($this)
;
} |
Beta Was this translation helpful? Give feedback.
-
{% block kreyu_data_table_date_range_widget %}
<div class="flex items-center gap-2">
{{ form_widget(form.from, {'attr': {'placeholder': 'Date Range Filter From Placeholder' | trans({}, 'KreyuDataTable') }}) }}
{{ form_widget(form.to, {'attr': {'placeholder': 'Date Range Filter To Placeholder' | trans({}, 'KreyuDataTable') }}) }}
</div>
{% endblock %} |
Beta Was this translation helpful? Give feedback.
It's called
kreyu_data_table_date_range_widget
- in Bootstrap theme it uses input group to display two child fields in single line:data-table-bundle/src/Resources/views/themes/bootstrap_5.html.twig
Lines 980 to 986 in 2df63d0