public function actionRegistration() { if (Yii::app()->user->id) { $this->redirect(array($this->module->profileUrl)); return; } $regForm = $this->createRegistrationForm(); $personIdent = new PersonIdentifier('userApply'); if (isset($_POST['PersonIdentifier']['type'])) { $personIdent->type = $_POST['PersonIdentifier']['type']; } else { $personIdent->type = Yii::app()->getModule('personIdentifier')->defaultIdentifierType; } // $this->performAjaxValidation($regForm, 'RegistrationForm'); // $this->performAjaxValidation($personIdent, 'PersonIdentifier'); if ($this->request->isPostRequest) { if (!isset($_POST['RegistrationForm'])) { throw new CHttpException(403); } $regForm->attributes = $_POST['RegistrationForm']; $personIdent->attributes = $_POST['PersonIdentifier']; $valid = $regForm->validate(); $valid = $personIdent->validate() && $valid; $this->personIdent = $personIdent; if ($valid) { $registration = new UserRegistration($regForm); $registration->onAfterRecordsCreated = array($this, 'afterRecordsCreated'); try { $registration->run(); Yii::app()->user->setFlash('success', "We have created account especially for you! Please check your mail, and confirm registration"); $this->redirect(array($this->module->loginUrl)); } catch (Exception $exc) { throw $exc; // Yii::app()->user->setFlash('error', "Sorry, but something went wrong during registration process. Try later or contact with administrator"); } } } $this->render($this->module->registrationView, array('model' => $regForm, 'personIdent' => $personIdent)); }
protected function switchIdentifier($type) { $this->select("id=PersonIdentifier_type", 'label=' . $type); $ident = new PersonIdentifier(); $type = array_search($type, PersonIdentifier::getTypesCaptions()); $ident->type = $type; $attrs = $ident->getTypeAttributeNames(); foreach ($attrs as $attrName) { $this->waitForPresent('css=#person-identifier-fields #PersonIdentifier_' . $attrName); } }
<?php $module = Yii::app()->getModule('personIdentifier'); if (empty($form)) { $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('id' => 'person-identifier', 'enableAjaxValidation' => false, 'enableClientValidation' => false, 'type' => 'vertical', 'htmlOptions' => array('enctype' => 'multipart/form-data'))); $shouldCloseWidget = true; echo $form->errorSummary($model); } echo $form->dropDownListRow($model, 'type', PersonIdentifier::getTypesCaptions(), array('class' => 'span12')); Yii::app()->clientScript->registerCss('personIdentifierStyles', "input[type=\"file\"] {" . "margin-bottom: 10px;" . "}" . ".popover {" . "max-width: " . ($module->identifierExampleMaxWidth + 5) . "px;" . "max-height: " . ($module->identifierExampleMaxHeight + 5) . "px;" . "}" . ".popover-content {" . "padding: 2px;" . "}" . ".popover-content img {" . "max-width: {$module->identifierExampleMaxWidth}px;" . "max-height: {$module->identifierExampleMaxHeight}px;" . "}"); ?> <script type="text/javascript"> $('#PersonIdentifier_type').change(function() { $('#identifier-input-container').block({ message: null, overlayCSS: { backgroundColor: '#f5f5f5', opacity: 0.3, cursor: 'wait' } }); $('#identifier-input-container').smartLoad( '<?php echo $this->owner->createUrl('/personIdentifier/types/getFormAttrs/'); ?> ', {type: this.value}, function() { $('#identifier-input-container').unblock(); } );