public function actionElementForm($id, $patient_id, $previous_id = null)
{
// first prevent invalid requests
$element_type = ElementType::model()->findByPk($id);
if (!$element_type) {
throw new CHttpException(404, 'Unknown ElementType');
}
$patient = Patient::model()->findByPk($patient_id);
if (!$patient) {
throw new CHttpException(404, 'Unknown Patient');
}
// Clear script requirements as all the base css and js will already be on the page
Yii::app()->assetManager->reset();
$this->patient = $patient;
$this->setFirmFromSession();
$this->episode = $this->getEpisode();
// allow additional parameters to be defined by module controllers
// TODO: Should valid additional parameters be a property of the controller?
$additional = array();
foreach (array_keys($_GET) as $key) {
if (!in_array($key, array('id', 'patient_id', 'previous_id'))) {
$additional[$key] = $_GET[$key];
}
}
// retrieve the element
$element = $this->getElementForElementForm($element_type, $previous_id, $additional);
$this->open_elements = array($element);
$form = Yii::app()->getWidgetFactory()->createWidget($this, 'BaseEventTypeCActiveForm', array('id' => 'clinical-create', 'enableAjaxValidation' => false, 'htmlOptions' => array('class' => 'sliding')));
$this->renderElement($element, 'create', $form, null, array('previous_parent_id' => $previous_id), false, true);
}