コード例 #1
0
 public static function populateCountryStateCity(PersonInterface $person, FormInterface $form)
 {
     $country = $person->getCountry();
     $state = $person->getState();
     $city = $person->getCity();
     $countryName = '';
     if ($country) {
         $countryName = $country->getName();
     }
     $form->add('country', 'text', array('required' => true, 'mapped' => false, 'read_only' => true, 'data' => $countryName));
     $stateName = '';
     if ($state) {
         $stateName = $state->getName();
     }
     $form->add('state', 'text', array('required' => true, 'read_only' => 'true', 'mapped' => false, 'read_only' => true, 'data' => $stateName));
     $cityName = '';
     if ($city) {
         $cityName = $city->getName();
     }
     $form->add('city', 'text', array('required' => true, 'read_only' => 'true', 'mapped' => false, 'read_only' => true, 'data' => $cityName));
     return $form;
 }