Is it possible to render a view into a formmapper? The situation is like this:
/**
* @param FormMapper $formMapper
*/
protected function configureFormFields(FormMapper $formMapper)
{
$formMapper
->tab('Company')
->with('Info')
->add('name')
->end()
->end()
->tab('Abonnementen')
->with('Abonnementen', array('class' => 'col-md-12'))
//Render a partial twig here
->end()
;
}
This is in my twig:
<form class="form-horizontal" action="" method="post" style="margin-top:15px;">
<div class="row">
<div class="col-md-12">
<div class="box box-primary">
<div class="box-header"><h4 class="box-title">Abonnementen</h4></div>
<div class="box-body">
<table class="table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Description</th>
<th>Price</th>
<th>Active</th>
</tr>
</thead>
<tbody>
{% for abonnement in abonnementen %}
<tr>
<td>{{ abonnement.name }}</td>
<td>{{ abonnement.description }}</td>
<td>€ {{ abonnement.price }}</td>
<td>
<input type="checkbox" name="{{ abonnement.id }}[active]"
{% if abonnement.active %}
checked="checked"
{% endif %}>
</td>
</tr>
{% endfor %}
<tr>
<td colspan="4">
<input type="submit" class="btn btn-primary" value="Save" name="abonnement_save">
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</form>
Is it even possible to load this into my tab in my formmapper?
I think that is possible to do something similar. You want to inject your form into base sonata form. It is possible but at the end you get something like this:
<form> # form from sonata
<form> #your custom form
</form>
</form>
I don't recommend it.
Formmaper build form from formBuilder and you can define template(html) of your form field in standart way:
http://symfony.com/doc/current/cookbook/form/form_customization.html
I reccommend you to override sonata template name 'edit' and add there your code as another form.
public function configure()
{
$this->setTemplate('edit', 'ApplicationM2MNewsletterBundle:CRUD:empty_form.html.twig');
}