开发者

Symfony Error on Form Submission .... "must be an instance of varchar, string given,"

开发者 https://www.devze.com 2023-04-06 18:19 出处:网络
Running Symfony2 Upon submitting a form, here is the error I get: Catchable Fatal Error: Argument 1 passed to Depot\\StarterBundle\\Entity\\Application::setPropAddr() must be an ins开发者_开发知识库

Running Symfony2

Upon submitting a form, here is the error I get:

    Catchable Fatal Error: Argument 1 passed to Depot\StarterBundle\Entity\Application::setPropAddr() must be an ins开发者_开发知识库tance of varchar, string given, called in C:\wamp\www\Symfony\vendor\symfony\src\Symfony\Component\Form\Util\PropertyPath.php on line 346 and defined in C:\wamp\www\Symfony\src\Depot\StarterBundle\Entity\Application.php line 211 

Here is the block in question:

 /**
 * Set prop_addr
 *
 * @param varchar $propAddr
 */
public function setPropAddr(\varchar $propAddr)
{
    $this->prop_addr = $propAddr;
}

/**
 * Get prop_addr
 *
 * @return varchar 
 */
public function getPropAddr()
{
    return $this->prop_addr;
}

If I remove the /varchar from "\varchar $propAddr" in the setPropAddr() function, it works. But this entity was created from the command line so there must be a bigger issue here.

And here is the line in my Application.orm.yml

 prop_addr:
    type: string(255)

What is the issue?


public function setPropAddr(\varchar $propAddr) This is clearly wrong, seems like it have taken the DB type and added that as a Class TypeHint. Generally you shouldn't autogenerate anything with Doctrine2 (Will keep you from overwriting stuff and fixing wrongly generated setters)

0

精彩评论

暂无评论...
验证码 换一张
取 消