I have 2 entities: User and Location.
namespace mk\MyBundle\Entity;
use mk\MyBundle\Entity\Location;
class User
{
protected $user_id;
protected $first_name;
protected $last_name;
protected $location;
}
and
namespace mk\MyBundle\Entity;
class Location
{
public $country_id;
public $country_name;
public $state_id;
public $state_name;
public $city_id;
public $city_name;
}
I'm storing user's location as a location object, within proper variable.
In profile edit page I've prepared FormType class UserType's where location is shown using nested object call:
$builder->add('location.country_id', 'country')
And when I'm using that with plain {{ form_rest(form) }} everything is ok, but when I want to address that stuff directly, like:
{{ form_widget(form.location.country_id) }}
Twig throws me an error: Method "location" for object "Symfony\Component\Form\FormView" does not exist in MyBundle:User:profile.html.twig at line 69
What I'm doing wrong? Thanks in advance.
Updated