nfq-eta/time-duration-type

Form type for durations

v0.1.1 2018-02-09 09:48 UTC

This package is auto-updated.

Last update: 2024-11-15 04:23:22 UTC


README

Allows to input durations in format hh:mm or hh:mm:ss

Options

store_as

Model data format

Valid values are

  • seconds(Nfq\Bundle\TimeBundle\Form\Type\TimeDurationType::STORE_SECONDS)
  • minutes(Nfq\Bundle\TimeBundle\Form\Type\TimeDurationType::STORE_MINUTES)(default)

display_seconds

boolean for displaying seconds parts. Must be true for when storing as seconds. Defaults to false

Minutes stored as seconds example

    /**
     * {@inheritdoc}
     */
    public function buildForm(FormBuilderInterface $builder, array $options): void
    {
        $builder
            ->add(
                'time',
                TimeDurationType::class,
                [
                    'store_as' => TimeDurationType::STORE_SECONDS,
                    'display_seconds' => false,
                    'required' => false,
                ]
            );
    }