Пример #1
0
 /**
  * (non-PHPdoc).
  *
  * @see BaseEventTypeController::setPOSTManyToMany()
  */
 protected function setElementComplexAttributesFromData($element, $data, $index = null)
 {
     foreach (array('left', 'right') as $side) {
         if (get_class($element) == 'Element_OphTrIntravitrealinjection_Complications') {
             if (isset($data['Element_OphTrIntravitrealinjection_Complications'][$side . '_complications'])) {
                 $complications = array();
                 foreach ($data['Element_OphTrIntravitrealinjection_Complications'][$side . '_complications'] as $comp_id) {
                     if ($comp = OphTrIntravitrealinjection_Complication::model()->findByPk($comp_id)) {
                         $complications[] = $comp;
                     }
                 }
                 $element->{$side . '_complications'} = $complications;
             }
         } elseif (get_class($element) == 'Element_OphTrIntravitrealinjection_Treatment') {
             foreach (array('pre', 'post') as $stage) {
                 if (isset($data['Element_OphTrIntravitrealinjection_Treatment'][$side . '_' . $stage . '_ioploweringdrugs'])) {
                     $ioplowerings = array();
                     foreach ($data['Element_OphTrIntravitrealinjection_Treatment'][$side . '_' . $stage . '_ioploweringdrugs'] as $ioplowering_id) {
                         if ($ioplowering = OphTrIntravitrealinjection_IOPLoweringDrug::model()->findByPk($ioplowering_id)) {
                             $ioplowerings[] = $ioplowering;
                         }
                     }
                     $element->{$side . '_' . $stage . '_ioploweringdrugs'} = $ioplowerings;
                 }
             }
         }
     }
 }
 * @license http://www.gnu.org/licenses/gpl-3.0.html The GNU General Public License V3.0
 */
?>

<?php 
$html_options = array('options' => array(), 'empty' => '- Please select -', 'div_id' => get_class($element) . '_' . $side . '_complications', 'label' => 'Complications');
$complications = OphTrIntravitrealinjection_Complication::model()->activeOrPk($element->complicationValues)->findAll();
foreach ($complications as $complication) {
    $html_options['options'][(string) $complication->id] = array('data-order' => $complication->display_order, 'data-description_required' => $complication->description_required);
}
echo $form->multiSelectList($element, get_class($element) . '[' . $side . '_complications]', $side . '_complications', 'id', CHtml::listData($complications, 'id', 'name'), $element->ophtrintravitinjection_complication_defaults, $html_options, false, false, null, false, false, array('field' => 6));
$show_desc = false;
if (@$_POST[get_class($element)] && ($complication_ids = @$_POST[get_class($element)][$side . '_complications'])) {
    $criteria = new CDbCriteria();
    $criteria->addInCondition('id', $complication_ids);
    $complications = OphTrIntravitrealinjection_Complication::model()->findAll($criteria);
} else {
    $complications = $element->{$side . '_complications'};
}
foreach ($complications as $complication) {
    if ($complication->description_required) {
        $show_desc = true;
    }
}
?>

<div id="div_Element_OphTrIntravitrealinjection_Complications_<?php 
echo $side;
?>
_oth_descrip" class="row field-row<?php 
if (!$show_desc) {
 public function getophtrintravitinjection_complication_defaults()
 {
     $ids = array();
     foreach (OphTrIntravitrealinjection_Complication::model()->active()->findAll('`default` = 1') as $item) {
         $ids[] = $item->id;
     }
     return $ids;
 }