public function populate(array $values) { $baseDir = $this->getView()->BaseUrl(); $content = ''; $isSaved = false; $currentYear = date('Y', time()); if (empty($values['MP_YearsParticipate'])) { $values['MP_YearsParticipate'] = $currentYear . ','; } $isSaved = preg_match('/' . $currentYear . '/', $values['MP_YearsParticipate']); if (!$isSaved && $values['MP_Category'] == 46) { $lastChar = strrpos($values['MP_YearsParticipate'], ',', -1); if (!$lastChar) { $values['MP_YearsParticipate'] .= ','; } $values['MP_YearsParticipate'] .= $currentYear . ','; } parent::populate($values); if (!empty($values['firstP'])) { $subject = '##ROLE## : ' . $this->getView()->link('##HREF##', '##FNAME## ##LNAME##'); if ($values['firstP'][4]) { $subject .= " (reçu pour impôts)"; } $href = $baseDir . '/users/index/general/actionKey/edit/id/' . $values['firstP']['1']; $values['firstP']['1'] = $href; $content = str_replace(array('##ROLE##', '##HREF##', '##FNAME##', '##LNAME##'), $values['firstP'], $subject); } if (!empty($values['secP'])) { $subject = '##ROLE## : ' . $this->getView()->link('##HREF##', '##FNAME## ##LNAME##'); if ($values['secP'][4]) { $subject .= " (reçu pour impôts)"; } $href = $baseDir . '/users/index/general/actionKey/edit/id/' . $values['secP']['1']; $values['secP']['1'] = $href; $content .= '<br />'; $content .= str_replace(array('##ROLE##', '##HREF##', '##FNAME##', '##LNAME##'), $values['secP'], $subject); } if (empty($values['firstP']) || empty($values['secP'])) { // $img = <img title="Supprimer" alt="" src=""> $img = $this->getView()->image('/extranet/icons/button_add.png', array('title' => 'Ajouter')); $href = $this->getView()->BaseUrl() . '/parent/index/list/actionKey/add/child/' . $values['MP_GenericProfileId']; $link = $this->getView()->link($href, $img . 'Ajouter les parents / représentants légaux', array('class' => 'addParents')); if (!empty($content)) { $content .= '<br />'; } $content .= $link; } $firstP = new Cible_Form_Element_Html('parents', array('value' => $content)); $firstP->setDecorators(array('ViewHelper', array('label', array('placement' => 'prepend')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'left clearLeft')))); $this->getDisplayGroup('other')->addElement($firstP); $firstP->setOrder(1); }
public function populate(array $values) { $diseasesList = $this->_object->_diseasesSrc(); $oDiseases = new DiseasesDetailsObject(); $dData = $oDiseases->findData(array($oDiseases->getForeignKey() => $values[$this->_object->getForeignKey()])); $fieldSet = $this->getDisplayGroup('diseases'); $i = 6; foreach ($diseasesList as $id => $disease) { $tmpForm = new FormDiseasesDetails(array('object' => $oDiseases, 'isXmlHttpRequest' => true)); if (!empty($values['MR_Diseases']) && in_array($id, $values['MR_Diseases'])) { $oDiseases->setFilters(array($oDiseases->getForeignKey() => $values[$this->_object->getForeignKey()], 'DD_DiseaseId' => $id)); $data = $oDiseases->getAll(); $data[0]['DD_TypeMedic'] = explode(',', $data[0]['DD_TypeMedic']); $tmpForm->populate($data[0]); } $elems = $tmpForm->getElements(); $test = new Zend_Form_SubForm(); $test->setDisableLoadDefaultDecorators(true); $test->addElements($elems); $test->removeDecorator('DtDdWrapper'); $test->setLegend('Détails pour ' . $disease); $test->setAttrib('class', 'infosFieldsetParent fieldsetDiseaseDetails'); $test->setOrder($i++); $this->addSubForm($test, 'dd_' . $id); } parent::populate($values); }