I have a simple symfony 2 setup with Doctrine ORM and a db with some underscore seperated field names (for instance "error_page"). Querying this never gives a result (getTitle does give a result, getErrorPage is always empty) and symfony gives me an error:
Method "error_page" for object "My\CmsBundle\Document\Website" does not exist in MyCmsBundle:Default:dashboard.html.twig at line 5
I can't figure out why... My Document looks like this:
<?php
// src/My/CmsBundle/Document/Website.php
namespace My\CmsBundle\Document;
use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
/**
* @MongoDB\Document(
* collection="websites"
* )
*/
class Website
{
/**
* @MongoDB\Id
*/
protected $id;
/**
* @MongoDB\String
*/
protected $slug;
/**
* @MongoDB\Field(type="string", name="error_page")
*/
protected $error_page = "";
/**
* @MongoDB\String
*/
protected $title;
/**
* @MongoDB\String(name="seo_title")
*/
protected $seo_title;
/**
* @MongoDB\String
*/
protected $seo_description;
/**
* @MongoDB\Collection
*/
protected $url = array();
/**
* Get id
*
* @return id $id
*/
public function getId()
{
return $this->id;
}
/**
* Set slug
*
* @param string $slug
* @return self
*/
public function setSlug($slug)
{
$this->slug = $slug;
return $this;
}
/**
* Get slug
*
* @return string $slug
*/
public function getSlug()
{
return $this->slug;
}
/**
* Set title
*
* @param string $title
* @return self
*/
public function setTitle($title)
{
$this->title = $title;
return $this;
}
/**
* Get title
*
* @return string $title
*/
public function getTitle()
{
return $this->title;
}
/**
* Set errorPage
*
* @param string $errorPage
* @return self
*/
public function setErrorPage($errorPage)
{
$this->error_page = $errorPage;
return $this;
}
/**
* Get errorPage
*
* @return string $errorPage
*/
public function getErrorPage()
{
return $this->error_page;
}
/**
* Set url
*
* @param collection $url
* @return self
*/
public function setUrl($url)
{
$this->url = $url;
return $this;
}
/**
* Get url
*
* @return collection $url
*/
public function getUrl()
{
return $this->url;
}
/**
* Set seoTitle
*
* @param string $seoTitle
* @return self
*/
public function setSeoTitle($seoTitle)
{
$this->seo_title = $seoTitle;
return $this;
}
/**
* Get seoTitle
*
* @return string $seoTitle
*/
public function getSeoTitle()
{
return $this->seo_title;
}
/**
* Set seoDescription
*
* @param string $seoDescription
* @return self
*/
public function setSeoDescription($seoDescription)
{
$this->seo_description = $seoDescription;
return $this;
}
/**
* Get seoDescription
*
* @return string $seoDescription
*/
public function getSeoDescription()
{
return $this->seo_description;
}
}
Document creation via this document works fine by the way. The field name is also set to error_page as expected... I'm at a loss here :S
{{ document.errorPage }}