My modal content is done via ajax.
There are 2 fields: a date picker and a time picker.
None of them worked. I added the tailwind js using {{ encore_entry_script_tags('app') }} on the loaded content, and the date picker work as expected, but not the timepicker. If the same datepicker field is loaded with the page, then it works properly.
https://tailwind-elements.com/docs/standard/forms/timepicker/
Here is my code / config i am using with symfony 6.0:
assets/app.js
/*
* Welcome to your app's main JavaScript file!
*
* We recommend including the built version of this JavaScript file
* (and its CSS file) in your base layout (base.html.twig).
*/
// any CSS you import will output into a single css file (app.css in this case)
import './styles/app.scss';
import './bootstrap';
import './js/jqueryPropotype';
import './js/arrayLink';
import 'tw-elements';
webpack.config.js
...
.addEntry('app', './assets/app.js')
...
and my content loaded via ajax:
{# form.html.twig #}
{{ form_start(form, { 'attr':{'class': 'form-horizontal' } }) }}
<div class="row">
<div class="col-md-6 col-sm-12 datepicker mb-3" data-mdb-toggle-button="false">
{{ form_row(form.dateStart) }}
</div>
<div class="col-md-6 col-sm-12 timepicker mb-3" data-mdb-with-icon="false" id="input-toggle-timepicker">
{{ form_row(form.timeStart) }}
</div>
</div>
{{ form_end(form) }}
{{ encore_entry_script_tags('app') }}
My form builder:
$builder->add(
'dateStart',
DateTimeType::class,
[
'label_html' => true,
'label' => $this->translator->trans('pro.appointment.form.dateStart', [], 'pro'),
'widget' => 'single_text',
'data' => $dateStart,
'input' => 'datetime',
'html5' => false,
'format' => 'dd/MM/yyyy',
'attr' => [
'data-mdb-toggle' => "datepicker"
],
]
)->add(
'timeStart',
DateTimeType::class,
[
'label_html' => true,
'label' => $this->translator->trans('pro.appointment.form.timeStart', [], 'pro'),
'widget' => 'single_text',
'data' => $dateStart,
'input' => 'datetime',
'html5' => false,
'format' => 'HH:HH',
'attr' => [
'data-mdb-toggle' => "input-toggle-timepicker"
],
]
);
My form display this
When i click on the datetype element:
Is there any trouble with this component on html loaded with ajax?

