I am using symfony2. Actually i have created form using form type. but when i render the form, following error occurred
ContextErrorException: Catchable Fatal Error: Argument 1 passed to Symfony\Component\Form\FormRenderer::searchAndRenderBlock() must be an instance of Symfony\Component\Form\FormView
Here is my code
Controller
$profile = new profile();
$myForm = $this->createForm(new ProfileFormType(), $profile);
return $this->render('ProfileBundle:Profle:profile.html.twig', array(
'form' => $myForm,
'vendor' => $vendor,
'productId' => $productId
));
profile.twig.html
<form action="{{ path('profile_new') }}" method="POST" {{ form_enctype(form) }} id="frmProfile">
<div class="box-body col-sm-6">
<div class="form-group">
<label class="control-label">First Name: </label>
{{ form_widget(form.firstName, { 'attr': { 'placeholder': 'Title', 'class': 'form-control'}}) }}
<div class="serverError">{{ form_errors(form.firstName) }}</div>
</div>
</div>
<div class="box-body col-sm-6">
<div class="form-group">
<label class="control-label">Last Name: </label>
{{ form_widget(form.lastName, { 'attr': { 'placeholder': 'Title', 'class': 'form-control'}}) }}
<div class="serverError">{{ form_errors(form.lastName) }}</div>
</div>
</div>
<div class="box-body col-sm-6">
<div class="form-group">
<label class="control-label">User Name: </label>
{{ form_widget(form.username, { 'attr': { 'placeholder': 'Title', 'class': 'form-control'}}) }}
<div class="serverError">{{ form_errors(form.username) }}</div>
</div>
</div>
</form>
What am i doing wrong?
$myForm->createView();
– Beginner