/** * Edits or adds a snippets. * * @param bool|int $id * * @throws CHttpException */ public function actionEdit($id = false) { if ($id) { $this->admin->setModelId($id); } $this->admin->setEditFields(array('site_id' => array('widget' => 'DropDownList', 'options' => CHtml::listData(Institution::model()->getCurrent()->sites, 'id', 'short_name'), 'default' => Yii::app()->request->getParam('site_id'), 'htmlOptions' => null, 'hidden' => false, 'layoutColumns' => null), 'letter_string_group_id' => array('widget' => 'DropDownList', 'options' => CHtml::listData(LetterStringGroup::model()->findAll(), 'id', 'name'), 'default' => Yii::app()->request->getParam('group_id'), 'htmlOptions' => null, 'hidden' => false, 'layoutColumns' => null), 'name' => 'text', 'body' => array('widget' => 'CustomView', 'viewName' => '//admin/generic/shortcodeText', 'viewArguments' => array('model' => $this->admin->getModel())), 'event_type' => array('widget' => 'DropDownList', 'options' => CHtml::listData(EventType::model()->findAll(), 'class_name', 'name'), 'htmlOptions' => array('empty' => '- Select -'), 'hidden' => false, 'layoutColumns' => null), 'element_type' => array('widget' => 'DropDownList', 'options' => CHtml::listData(ElementType::model()->findAll(), 'class_name', 'name'), 'htmlOptions' => array('empty' => '- Select -'), 'hidden' => false, 'layoutColumns' => null))); $this->admin->editModel(); }
$event_types[$event_type->class_name] = array(); foreach ($event_type->elementTypes as $elementType) { $event_types[$event_type->class_name][] = $elementType->class_name; } } if (isset($_GET['patient_id'])) { $patient = Patient::model()->findByPk($_GET['patient_id']); } else { $patient = Yii::app()->getController()->patient; } $with = array('firmLetterStrings' => array('condition' => 'firm_id is null or firm_id = :firm_id', 'params' => array(':firm_id' => $firm->id), 'order' => 'firmLetterStrings.display_order asc'), 'subspecialtyLetterStrings' => array('condition' => 'subspecialty_id is null', 'order' => 'subspecialtyLetterStrings.display_order asc'), 'siteLetterStrings' => array('condition' => 'site_id is null or site_id = :site_id', 'params' => array(':site_id' => Yii::app()->session['selected_site_id']), 'order' => 'siteLetterStrings.display_order')); if ($firm->getSubspecialtyID()) { $with['subspecialtyLetterStrings']['condition'] = 'subspecialty_id is null or subspecialty_id = :subspecialty_id'; $with['subspecialtyLetterStrings']['params'] = array(':subspecialty_id' => $firm->getSubspecialtyID()); } foreach (LetterStringGroup::model()->with($with)->findAll(array('order' => 't.display_order')) as $string_group) { $strings = $string_group->getStrings($patient, $event_types); ?> <div class="field-row"> <?php echo $form->dropDownListNoPost(strtolower($string_group->name), $strings, '', array('empty' => '- ' . $string_group->name . ' -', 'nowrapper' => true, 'class' => 'stringgroup full-width', 'disabled' => empty($strings))); ?> </div> <?php } ?> </div> <div class="large-<?php echo $layoutColumns['field']; ?> column end">
protected function beforeAction($action) { $this->admin = new Admin(LetterStringGroup::model(), $this); $this->admin->setModelDisplayName('Letter Snippet Group'); return parent::beforeAction($action); }
public function getStringGroups() { return LetterStringGroup::model()->findAll(array('order' => 'display_order')); }