Ejemplo n.º 1
0
 public function configure()
 {
     parent::configure();
     //Widgets
     $this->setWidget('school_year_id', new sfWidgetFormReadOnly(array('plain' => false, 'value_callback' => array('SchoolYearPeer', 'retrieveByPk'))));
     $school_year = SchoolYearPeer::retrieveCurrent();
     $this->setDefault('school_year_id', $school_year->getId());
     $criteria_career = new Criteria();
     $criteria_career->add(CareerSchoolYearPeer::SCHOOL_YEAR_ID, $school_year->getId());
     $this->setWidget('career_school_year_id', new sfWidgetFormPropelChoice(array('model' => 'CareerSchoolYear', 'criteria' => $criteria_career, 'add_empty' => true)));
     $w = new sfWidgetFormChoice(array('choices' => array()));
     $this->widgetSchema['year'] = new dcWidgetAjaxDependence(array('dependant_widget' => $w, 'observe_widget_id' => 'course_career_school_year_id', "message_with_no_value" => "Seleccione una carrera y apareceran los años que correspondan", 'get_observed_value_callback' => array(get_class($this), 'getYears')));
     //Check if all the subjects has the same CareerSchoolYear
     $career_school_year = $this->getObject()->getCareerSchoolYear();
     $career_school_year_id = is_null($career_school_year) ? null : $career_school_year->getId();
     $this->getWidget('career_school_year_id')->setDefault($career_school_year_id);
     //Check if all the subjects has the same Year
     $year = $this->getObject()->getYear();
     $this->getWidget('year')->setDefault($year);
     $widget = new sfWidgetFormPropelChoice(array('model' => 'CareerSubjectSchoolYear', 'multiple' => true));
     $this->widgetSchema['course_subjects'] = new dcWidgetAjaxDependence(array('dependant_widget' => $widget, 'observe_widget_id' => 'course_year', "message_with_no_value" => "Seleccione una carrera y un año", 'get_observed_value_callback' => array(get_class($this), 'getSubjects')));
     //Validators
     $this->setValidator('career_school_year_id', new sfValidatorPropelChoice(array('model' => 'CareerSchoolYear', 'criteria' => $criteria_career)));
     $this->setValidator('course_subjects', new sfValidatorPropelChoice(array('model' => 'CareerSubjectSchoolYear', 'required' => true, 'multiple' => true)));
     $this->setValidator('school_year_id', new sfValidatorPass());
     $this->setValidator('year', new sfValidatorNumber());
 }