1

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?

1
  • I forgot check this class(( There isn't add name in this class, thx for prompt Commented May 24, 2017 at 13:47

1 Answer 1

1

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',
    ));
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.