Answer the question
In order to leave comments, you need to log in
How to drive more than one entity parameter into one form field in Symfony 2?
Greetings. Need advice on the following situation:
1. There is a certain entity Geo, described by several parameters: city-ID, city-name, region-ID, region-name, region-ID, region-name.
2. There is a form in which a list of cities is pulled through the entity type, where property = city-name, and value = city-id.
3. I can't figure out how to make value = city-id remain as before, and property would become city-name ( area-name ), where area-name is needed only for user reference. In other words: how can property = city-name add region-name?
Thank you.
Answer the question
In order to leave comments, you need to log in
Thank you all - the problem is solved quite simply! As I suggested now: in Entity we add the necessary parameter to the getter:
/**
* Get city_name
* @return string
*/
public function getCityName()
{
return $this->city_name . ' : ' . $this->getDistrictName();
}
/**
* Get city_name
* @return string
*/
public function getCityName()
{
return $this->getDistrictName() . ' => ' . $this->city_name);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question