15 minute interval Symfony 5 widget=> single_text

I am a Beginner in the dev world!

I am trying to use Symfony 5’s default timepicker with widget=>single_text and it works fine.

I would just like to set a 15 minute interval option (and make hours selectable only between 8 and 20) in the picker.

I have already done a lot of search but did not find anything.

I am creating a traditional web app (not an Android app).

Here is the code of my concerned php file (it works but only if I set widget=>choice):

class BookingType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('beginAt', DateTimeType::class, 
            [
                'widget' => 'single_text',
                'hours' => range(8, 20),
                'minutes' => [00, 15, 30, 45],
            ])
            ->add('endAt', DateTimeType::class, 
            [
                'widget' => 'single_text',
                'hours' => range(8, 20),
                'minutes' => [00, 15, 30, 45],
            ])

        ;

    }

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *