在yii中提交调用函数

时间:2015-11-25 08:48:53

标签: yii

我想在yii中提交表单时调用函数。在我的表单中,我启用了validateOnSubmit

当处于调用函数形式Onsubmit时意味着它将在两次调用函数。

我的编码,

<?php
            $form = $this->beginWidget('CActiveForm', array(
                'id' => 'question-form',
                // Please note: When you enable ajax validation, make sure the corresponding
                // controller action is handling ajax validation correctly.
                // There is a call to performAjaxValidation() commented in generated controller code.
                // See class documentation of CActiveForm for details on this.
                'enableAjaxValidation' => true,
                'enableClientValidation' => false,
                'clientOptions' => array(
                    'validateOnSubmit' => true,
                    'validateOnChange' => false,
                ),
                'htmlOptions' => array('onsubmit' => 'return checkmultiple()',),

            ));
            ?>


            <div class="form-group">
                <?php echo $form->labelEx($model, 'question_title'); ?>
            <?php echo $form->textField($model, 'question_title', array('size' => 50, 'maxlength' => 250, 'class' => 'form-control')); ?>
            <?php echo $form->error($model, 'question_title'); ?>
            </div>
                <?php if ($tileAssigned == Yii::app()->const->FLAG_ZERO) { ?>
                <div class="form-group">
                    <?php echo $form->labelEx($model, 'type', array('label' => 'Is Multiple Choice')); ?>
<?php echo $form->radioButtonList($model, 'type', $yesnoList, array('separator' => '', 'onchange' => 'questionTypeChange(this.value);', 'class' => '')); ?>
                <?php echo $form->error($model, 'type'); ?>
                </div>

我正在调用函数checkmultiple意味着它会调用两次。

function checkmultiple()
{
}

0 个答案:

没有答案
相关问题