Yii Framework Forum: Регистрация В Несколько Шагов - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Регистрация В Несколько Шагов Rate Topic: -----

#1 User is offline   bot 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 27
  • Joined: 22-December 13

Posted 08 March 2014 - 11:17 AM

Необходимо осуществить регистрацию в несколько шагов.

Для этого в siteController я создал actionRegistration()

public function actionRegistration()
        {
                $userModel = new User;
                $companyModel = new Company;

                if(isset($_POST['User']))
                {
                        $userModel->attributes=$_POST['User'];
                        $userModel->save();             
                }

                if(isset($_POST['Company']))
                {
                        $companyModel->attributes=$_POST['Company'];
                        $companyModel->save();          
                }               

                 $this->render('registration',array(
                   'userModel'=>$userModel,
                   'companyModel'=>$companyModel,
    )); 
        }


и в папке views/site/ я создал файл registration.php

<div id="container">
<form action="#" method="post">    
<div id="first_step">
<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
        'id'=>'user-form',
        'enableAjaxValidation'=>true,
)); ?>

        <?php echo $form->errorSummary($userModel); ?>

        <div class="row">
                <?php echo $form->labelEx($userModel,'name'); ?>
                <?php echo $form->textField($userModel,'name',array('size'=>60,'maxlength'=>255, id=>"username")); ?>
                <?php echo $form->error($userModel,'name'); ?>
        </div>

        <div class="row">
                <?php echo $form->labelEx($userModel,'phone'); ?>
                <?php echo $form->textField($userModel,'phone',array('size'=>60,'maxlength'=>255, id=>"phone")); ?>
                <?php echo $form->error ($userModel,'phone'); ?>
        </div>

        <div class="row">
                <?php echo $form->labelEx($userModel,'mail'); ?>
                <?php echo $form->textField($userModel,'mail',array('size'=>60,'maxlength'=>255)); ?>
                <?php echo $form->error($userModel,'mail'); ?>
        </div>

        <div class="row">
                <?php echo $form->labelEx($userModel,'password'); ?>
                <?php echo $form->passwordField($userModel,'password',array('size'=>60,'maxlength'=>255)); ?>
                <?php echo $form->error($userModel,'password'); ?>
        </div>
        
        <div class="row">
            <?php echo $form->labelEx($userModel,'confirmPassword'); ?>
            <?php echo $form->passwordField($userModel,'confirmPassword'); ?>
            <?php echo $form->error($userModel,'confirmPassword'); ?>
        </div>

        <div class="row buttons">
                <?php echo CHtml::submitButton($userModel->isNewRecord ? 'Create' : 'Save'); ?>
        </div>

<?php $this->endWidget(); ?>
</div>
</div>
    
<div id="second_step">
<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
        'id'=>'company-form',
        'enableAjaxValidation'=>true,
)); ?>
    
                <?php echo $form->errorSummary($companyModel); ?>
        <div class="row">
                <?php echo $form->labelEx($companyModel,'name'); ?>
                <?php echo $form->textField($companyModel,'name',array('size'=>60,'maxlength'=>255)); ?>
                <?php echo $form->error($companyModel,'name'); ?>
        </div>

        <div class="row">
                <?php echo $form->labelEx($companyModel,'country'); ?>
                <?php echo $form->textField($companyModel,'country',array('size'=>60,'maxlength'=>255)); ?>
                <?php echo $form->error($companyModel,'country'); ?>
        </div>

        <div class="row">
                <?php echo $form->labelEx($companyModel,'sity'); ?>
                <?php echo $form->textField($companyModel,'sity',array('size'=>60,'maxlength'=>255)); ?>
                <?php echo $form->error($companyModel,'sity'); ?>
        </div>

        <div class="row">
                <?php echo $form->labelEx($companyModel,'oween_year'); ?>
                <?php echo $form->textField($companyModel,'oween_year'); ?>
                <?php echo $form->error($companyModel,'oween_year'); ?>
        </div>

        <div class="row buttons">
                <?php echo CHtml::submitButton($companyModel->isNewRecord ? 'Create' : 'Save'); ?>
        </div>
<?php $this->endWidget(); ?>
</div>
</div><!-- form -->
</form>
</div>


в ответ при загрузке формы, получаю ошибку
Use of undefined constant id - assumed 'id'
  <?php echo $form->textField($userModel,'name',array('size'=>60,'maxlength'=>255, id=>"username")); ?>


Помогите реализовать пожалуйста...
0

#2 User is offline   ORey 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,701
  • Joined: 20-April 09
  • Location:Moscow, Russia

Posted 08 March 2014 - 11:19 AM

id=>"username"

Недостаточно кавычек, надо больше кавычек.
И дальше там у Вас с phone та же история.
God is real unless declared as integer
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users