public function configure() { unset($this['person_id']); $person = $this->getObject()->getPerson(); if (is_null($person)) { $person = new Person(); $this->getObject()->setPerson($person); } $personForm = new PersonForm($person, array('related_class' => 'tutor', 'embed_as' => 'person')); $personForm->getValidator('phone')->setOption('required', true); $personForm->getValidator('birthdate')->setOption('required', false); $personForm->getValidator('identification_number')->setOption('required', false); $personForm->getValidator('identification_type')->setOption('required', false); $personForm->getValidator('sex')->setOption('required', false); $this->embedMergeForm('person', $personForm); $this->getWidget('occupation_id')->setLabel('Occupation'); $this->setWidget('student_list', new csWidgetFormStudentMany(array('criteria' => new Criteria()))); $this->getWidget('student_list')->setLabel('Students'); $this->setValidator('student_list', new sfValidatorPass(array('required' => false))); $this->setValidator('person-address', new sfValidatorPass(array('required' => false))); $this->setWidget('nationality', new sfWidgetFormChoice(array('choices' => BaseCustomOptionsHolder::getInstance('Nationality')->getOptions()))); $this->setValidator('nationality', new sfValidatorChoice(array('choices' => BaseCustomOptionsHolder::getInstance('Nationality')->getKeys(), 'required' => false))); $this->setDefault('student_list', array_map(create_function('$st', 'return $st->getStudentId();'), $this->getObject()->getStudentTutors())); }