symfony - Symfony2 Forms: How do I create a collection of 'entity' forms -
i have 1 many unidirectional relationship in model. user
has 1 of many status
.
using doctrine these mapped unidirectional many-to-many unique constraint on 1 of join columns.
i'd use symfony form select status status table, submit form , have symfony persist relationship.
i've tried 2 approaches:
using entity form type, produces error (due many-to-many relationship doctrine expects receive instance of
arraycollection
rather single status object.using collection entity objects. when using approach empty div id
status
rendered in form. expected select box appear containing status options.
here code. wrong?
entity code:
/** * @orm\manytomany(targetentity="status") */ protected $status;
form type code:
$builder->add('status', 'collection', array( 'type' => 'entity', 'allow_add' => true, 'options' => array( 'class' => 'sunflycorebundle:status', 'property' => 'name', )) );
form template code:
<form action="{{ path('_product_create_process') }}" method="post" {{ form_enctype(form) }}> {{ form_widget(form) }} <input type="submit" /> </form>
html rendered on page:
<div id="product_status" data-prototype="stuff wont render on so"></div>
Comments
Post a Comment