0

I have an application where user has to fill a lengthy form, so I split the form into three and created steps - Step 1, Step 2 etc. So it has to be convenient for users. Now I face a problem, after filling out the details, a text field shows an error. When using model->get Errors() the error is 'address cannot be blank'. When I use $_POST the arrays displays value for the field address. I started yii framework last week and I do not know where I have gone wrong. Any help appreciated.

The view code i use forloop to reduce my code -

         <fieldset>
        <?php if(!Yii::app()->user->hasFlash('success')): 
            Yii::app()->user->setFlash('warning','All Fields are mandatory!');
         endif; ?>
        <?php echo CHtml::errorSummary($model, null, null, array(
                    'class' => 'alert alert-danger col-lg-offset-2',
            )); ?>
        <?php     $rrr  =   -1;

            foreach($model->attributeLabels() as $a){ $rrr++; 
            if($rrr<27 && $rrr>=12){
            ?>
            <div class="form-group">
                <?php echo CHtml::activeLabel($model, $a, array('class' => 'col-lg-3 control-label')); ?>
                <div class="col-lg-7">
                    <?php echo CHtml::activeTextField($model,array_keys($model->attributeLabels())[$rrr],array('value'=>'a','size'=>255,'maxlength'=>255,'class'=>'form-control formtype1')); ?>

                </div>
            </div>
            <?php 
            }}
        ?>
        <?php     $rrr  =   -1;
            foreach($model2->attributeLabels() as $a){ $rrr++; 
            if($rrr>1 && $rrr<6){
            ?>
            <div class="form-group">
                <?php echo CHtml::activeLabel($model2, $a, array('class' => 'col-lg-3 control-label')); ?>
                <div class="col-lg-7">
                    <?php echo CHtml::activeTextField($model2,array_keys($model2->attributeLabels())[$rrr],array('value'=>'a','size'=>255,'maxlength'=>255,'class'=>'form-control formtype1')); ?>

                </div>
            </div>
            <?php 
            }}
        ?> 
        <div class="form-group">
            <div class="col-lg-offset-2 col-lg-10">
                <button class="btn btn-sm btn-primary" type="submit"><?php echo Yii::t("user", "Submit") ?></button>
            </div>
        </div>
        </fieldset>
    </form>
harshad14
  • 63
  • 1
  • 6

0 Answers0