Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function configure()
- {
- $this->useFields(array('name', 'description'));
- $this->mergeForm(new LocationForm(LocationPeer::retrieveByPK($this->getObject()->getLocation())));
- //Embed project quote template
- $pq = new Projectquote();
- $pq->setProject($this->getObject());
- $pq->setIsTemplate(true);
- $subForm = new ProjectquoteForm($pq);
- $pqSubForm = new sfForm();
- for($i = 0; $i < 2; $i++){
- $wp = new Workpackage();
- $wp->setProjectquote($pq);
- $wpf = new WorkpackageForm($wp);
- $pqSubForm->embedForm($i, $wpf);
- }
- $subForm->embedForm('packages', $pqSubForm);
- $this->embedForm('quote', $subForm);
- //$this->embedForm(new WorkpackageForm(), $this);
- $this->widgetSchema->setLabels(array(
- 'name' => 'Name',
- 'description' => 'Description'
- ));
- $this->setValidators(array(
- 'name' => new sfValidatorString(array('max_length' => 255, 'min_length' => 5)),
- 'description' => new sfValidatorString(array('max_length' => 255)),
- ));
- }
- public function save($con = null){
- parent::save();
- $this->updateLocationInfo();
- return $this->object;
- }
- protected function updateLocationInfo(){
- if(!is_null($locInfo = $this->getLocInfo())){
- $values = $this->getValues();
- if($locInfo->isNew()){
- $values['location_id'] = $this->object->getId();
- }
- $locInfo->fromArray($values, BasePeer::TYPE_FIELDNAME);
- $locInfo->save();
- }
- }
- protected function getLocInfo(){
- if(!$this->object->getLocation()){
- return new Location();
- }
- return $this->object->getLocation();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement