Reputation: 634
I have this photo form:
PhotoType.php
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('title');
And I embed this form in a form collection:
PhotoCollectionType.php
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('photos', 'collection', array(
'type' => new PhotoType($this->securityContext, $this->id),
'allow_add' => true,
'allow_delete' => true
))
->add('save', 'submit');
How can I get the form_widget
title alone?
I tried these:
{{ form(formCollection) }} -> works but not what i want
{{ form_widget(formCollection.title) }} -> no work
{{ form_widget(formCollection.photo.title) }} -> nop
{{ form_widget(formCollection.photos.title) }} -> oh wait !! .. no.
{{ form_widget(title) }} -> lol no.
Error being
Method "title" for object "Symfony\Component\Form\FormView" does not exist
edit : Oh and i should say the form is generated with js , for the allow_add allow_delete
Upvotes: 1
Views: 978
Reputation: 4210
{% for photo in form.photos %}
{{ form_widget(photo.title) }}
{% endfor %}
is this are you looking for?
Upvotes: 3