简体   繁体   中英

Display collection form on page load in Sonata Admin Bundle

Is there an option or a known way to display collection form on page load instead of clicking on "add" button in order to display it ?

I trigger a click event on page load but its not the expected behavior..

Any help would be much appreciated.

Alright, I achieved what I wanted by setting a default collection array on my form field, each Entity object in array imbricates a form, since I needed to display 3 form on page load I instanciated 3 entity, quite logic when I think of it now but a dedicated option could be nice though.

->add('details', CollectionType::class, [
            'data' => [new OfferDetail(), new OfferDetail(), new OfferDetail()],
            'label' => false,
            'required' => true,
            'type_options' => [
                'delete' => false,
            ],
        ], [
            'edit' => 'inline',
            'inline' => 'table'
        ])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM