public function actionAddEmailMessageRecipient($moduleClassName, $type, $recipientType, $rowNumber, $recipientRowNumber) { $form = new WizardActiveForm(); $form->id = WorkflowWizardView::getFormId(); $form->enableAjaxValidation = true; //ensures error validation populates correctly $wizardFormClassName = WorkflowToWizardFormAdapter::getFormClassNameByType($type); $model = WorkflowEmailMessageRecipientFormFactory::make($recipientType, $moduleClassName::getPrimaryModelName(), $type); $inputPrefixData = array($wizardFormClassName, ComponentForWorkflowForm::TYPE_EMAIL_MESSAGES, (int) $rowNumber, EmailMessageForWorkflowForm::TYPE_EMAIL_MESSAGE_RECIPIENTS, $recipientRowNumber); $adapter = new WorkflowEmailMessageRecipientToElementAdapter($model, $form, $recipientType, $inputPrefixData); $view = new EmailMessageRecipientRowForWorkflowComponentView($adapter, (int) $recipientRowNumber, $inputPrefixData); $content = $view->render(); $form->renderAddAttributeErrorSettingsScript($view::getFormId()); Yii::app()->getClientScript()->setToAjaxMode(); Yii::app()->getClientScript()->render($content); echo $content; }
/** * Process all attributes except 'emailMessageRecipients' first * @param $values * @param bool $safeOnly * @throws NotSupportedException if the post values data is malformed */ public function setAttributes($values, $safeOnly = true) { $recipients = null; if (isset($values[self::EMAIL_MESSAGE_RECIPIENTS]) && is_array($values[self::EMAIL_MESSAGE_RECIPIENTS])) { $recipients = $values[self::EMAIL_MESSAGE_RECIPIENTS]; unset($values[self::EMAIL_MESSAGE_RECIPIENTS]); $this->_emailMessageRecipients = array(); } parent::setAttributes($values, $safeOnly); if ($recipients != null) { $count = 0; foreach ($recipients as $temporaryKey => $recipientData) { if (!isset($recipientData['type'])) { throw new NotSupportedException(); } $form = WorkflowEmailMessageRecipientFormFactory::make($recipientData['type'], $this->_modelClassName, $this->_workflowType); $form->setAttributes($recipientData); $this->_emailMessageRecipients[] = $form; $this->_emailMessageRecipientsRealToTemporaryKeyData[] = $temporaryKey; $count++; } } }