保存消息不以yii形式显示

时间:2016-09-29 04:39:24

标签: php html yii

我有2个表单,第1个显示保存消息,但不显示在另一个表单上。

第一个视图给出确认消息,但第二个视图没有,数据保存在表格中。

gist for codes

在上面的要点中,您可以看到两者的控制器和视图。

1 个答案:

答案 0 :(得分:1)

您可以使用此代码解决方案。检查下面的消息代码集。

<强> view.php

    <div class="ibox">
        <div class="ibox-heading">
            <div class="ibox-title">
                <h3><?PHP echo(($model->isNewRecord) ? 'Create Fee Structure' : 'Update Fee Structure'); ?></h3>
            </div>
        </div>
        <!-- /.box-header -->
        <!-- Set Message start -->
        <?php if(Yii::app()->user->hasFlash('confirm')):?>
              <div class="info">
                  <?php echo Yii::app()->user->getFlash('confirm'); ?>
              </div>
        <?php endif; ?>
        <!-- Message end -->    

        <!-- form start -->
        <?php
        $form = $this->beginWidget('CActiveForm', array(
            'id' => 'fee_structure_form',
            'enableAjaxValidation' => true,
            'htmlOptions' => array(
                'enctype' => 'multipart/form-data',
                'role' => 'form'
            ),
            'clientOptions' => array(
                'validateOnSubmit' => true,
                'validateOnChange' => true,
                'validateOnType' => false,
            ),
        ));    ?>
        <div class="ibox-content">
            <div class="row">
                <div class="col-md-6 col-xs-12">
                    <div class="form-group">
                        <?PHP
                        echo $form->label($model, 'class_id');
                        echo $form->dropDownList($model, 'class_id', $studentClasses,array('placeholder' => 'Class', 'class' => 'form-control'));
                        echo $form->error($model,'class_id');
                        ?>
                    </div>
                    <div class="form-group">
                        <?PHP
                        echo $form->label($model, 'fee_type');
                        echo $form->dropDownList($model, 'fee_type', $feeTypes, array('placeholder' => 'Fee Type', 'class' => 'form-control'));
                        echo $form->error($model,'fee_type');
                        ?>
                    </div>

                    <div class="form-group">
                        <?PHP
                        echo $form->label($model, 'amount');
                        echo $form->textField($model, 'amount', array('placeholder' => 'Amount', 'class' => 'form-control'));
                        echo $form->error($model,'amount');
                        ?>
                    </div>

                    <div class="form-group">
                        <?PHP
                        echo $form->label($model, 'remarks');
                        echo $form->textField($model, 'remarks', array('placeholder' => 'Remarks', 'class' => 'form-control'));
                        echo $form->error($model,'remarks');
                        ?>
                    </div>   
                </div>
            </div>
        </div>
        <div class="ibox-footer col-md-12 col-xs-12" style="margin-bottom: 60px;">
            <button class="btn col-md-3 col-xs-12 btn-primary pull-left" type="submit">
                <?PHP echo Definations::SAVEFORM; ?>
            </button>
        </div>
        <?PHP
        $this->endWidget();
        ?>
    </div>