Having a the paradigm : - stations could have 0..N forecast models associated. - each forecast model could have 0..N stations related.
It means stations and forecasts tables get related by the in between table named station_forecast.
Following code fails shooting the error when twig file try to read the forecasts collection from a station object:
An exception has been thrown during the rendering of a template
Notice: Undefined index: station in /vendor/doctrine/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php line 1280
Station:
/**
* @ORM\OneToMany(targetEntity="ForecastBundle\Entity\StationForecast", mappedBy="***station***") <-- THIS 'STATION' THE ERROR REFERS.
*/
protected $forecasts`;
public function __construct()
{
$this->forecasts = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* @return Doctrine\Common\Collections\Collection
*/
function getForecasts() {
return $this->forecasts;
}
/**
* @param \ForecastBundle\Entity\StationForecast $station_forecast
*/
public function addForecasts(StationForecast $station_forecast)
{
$this->forecasts[] = $station_forecast;
}
StationForecast
/**
* @ORM\Id
* @ORM\Column(name="station_id", type="integer", nullable=false)
* @ORM\ManyToOne(targetEntity="EstacionsBundle\Entity\Station", inversedBy="forecasts")
*/
protected $station;
/**
* @ORM\Id
* @ORM\Column(name="forecast_id", type="integer", nullable=false)
* @ORM\ManyToOne(targetEntity="ForecastBundle\Entity\Forecast", inversedBy="stations")
*/
protected $forecast;
Forecast
/**
* @ORM\OneToMany(targetEntity="ForecastBundle\Entity\StationForecast", mappedBy="forecast")
*/
protected $stations;
public function addEstacions(\ForecastBundle\Entity\StationForecast $stations)
{
$this->stations[] = $stations;
}
/**
* @return Doctrine\Common\Collections\Collection
*/
public function getStations()
{
return $this->stations;
}
public function addStationForecast(\ForecastBundle\Entity\StationForecast $stations)
{
$this->stations[] = $stations;
}
Do you know what could happen? I'm getting crazy...