/** * Renders an inline record create/update form * @param object $model * @param bool $hasErrors */ public function renderInlineForm($model, $hasErrors, array $viewParams = array()) { $formModel = new ActionsQuickCreateFormModel(); $formModel->attributes = $_POST; $formModel->validate(); $actionType = $formModel->actionType; if ($actionType) { $secondModelName = $formModel->secondModelName; $secondModelId = $formModel->secondModelId; $associationType = X2Model::getAssociationType($secondModelName); $model->associationType = X2Model::getAssociationType($secondModelName); $tabClass = Publisher::$actionTypeToTab[$actionType]; $tab = new $tabClass(); $tab->namespace = get_class($this); $tab->startVisible = true; $this->owner->widget('Publisher', array('associationType' => $associationType, 'associationId' => $model->id, 'assignedTo' => Yii::app()->user->getName(), 'calendar' => false, 'renderTabs' => false, 'tabs' => array($tab), 'namespace' => $tab->namespace)); } switch ($actionType) { case 'action': case 'call': case 'note': case 'event': case 'time': case 'products': $this->owner->renderPartial('application.components.views.publisher.tabFormContainer', array('tab' => $tab, 'model' => $formModel->getAction(), 'associationType' => $model->associationType), false, true); break; default: parent::renderInlineForm($model, $hasErrors, array_merge(array('namespace' => get_class($this)), $viewParams)); //Yii::app()->controller->badRequest (Yii::t('app', 'Invalid action type')); } }
/** * Renders an inline record create/update form * @param object $model * @param bool $hasErrors */ public function renderInlineForm($model, array $viewParams = array()) { if (isset($_POST['modelId']) && !isset($model->associationId)) { $model->associationId = $_POST['modelId']; } if (isset($_POST['modelName']) && !isset($model->associationType)) { $model->associationType = $_POST['modelName']; } if ($model instanceof ActionFormModelBase) { echo CJSON::encode(array('status' => $model->hasErrors() ? 'userError' : 'success', 'page' => $this->owner->renderPartial('application.modules.actions.views.actions._' . lcfirst(preg_replace('/^(.*)FormModel/', '$1', get_class($model))) . 'Form', array('model' => $model), true, true))); } else { parent::renderInlineForm($model, array_merge(array('namespace' => get_class($this)), $viewParams)); } }