'Sonata Admin making array opening hours of shop

Using Sonata Admin panel I have $openingHours attribute:

/**
     * @ORM\Column(type="json", nullable=true)
     */
    private $openHours = [];

i would like to save a array in Json type, something like :

[
Monday=> [openFrom=>08:00, openTo=>12:00],
Tuesday=>[openFrom=>08:00, openTo=>12:00],
Wednesday=>[openFrom=>08:00, openTo=>12:00],
Thursday=>
...
]

Using $form in sonata I would like to be able to change opening hours from different day of week and after that It can be use in $show.

I tried to make it with choiceType::class - then there was problem to make Autocomplete hours/dayOfWeek and can save only one day.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source