I have entity good with fields: name, cost, description and etc. If I want to create new good or edit, I won't have field name in result html. That is in good entity:
/**
* @var string
*/
private $name;
/**
* Set name
*
* @param string $name
* @return Good
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
GoodController:
public function editAction(Request $request, Good $good)
{
...
$editForm = $this->createForm('Shop\ShopBundle\Form\GoodType', $good);
...
}
Create action has sample form. If I try call such code in twig template,
{{ form_label(edit_form.name) }}
I'll have
Neither the property "name" nor one of the methods "name()", "getname()"/"isname()" or "__call()" exist and have public access in class "Symfony\Component\Form\FormView".
What's wrong?
Your are missing the insctruction of the FormType
for every entity there should be a file EntityFormType.php
and there you will add your fields like this
$builder->add('name', null, array(
'required' => false,
'empty_data' => 'John Doe',
));