Note that there are some explanatory texts on larger screens.

plurals
  1. POValidation on cjuidialog modal window
    primarykey
    data
    text
    <p>I have a similar similar solution as posted on the wiki <a href="http://www.yiiframework.com/wiki/72/cjuidialog-and-ajaxsubmitbutton" rel="nofollow">here</a></p> <p>But i'm unable to have my validation rules working as expected. When I click on the submit buttom the modal window closes and nothing is saved if I don't fill all the required fields.</p> <p>Any idea of what i'm missing here? I have ajax validation "on" on the action and also on the view.</p> <p>Here's some pieces of my code:</p> <p>model Institution.php</p> <pre><code> public function actionAddnew() { $model=new Institution; // Ajax Validation enabled $this-&gt;performAjaxValidation($model); $flag=true; if(isset($_POST['Institution'])) { $flag=false; $model-&gt;attributes=$_POST['Institution']; if($model-&gt;save()) { //Return an &lt;option&gt; and select it echo CHtml::tag('option',array ( 'value'=&gt;$model-&gt;id, 'selected'=&gt;true ),CHtml::encode($model-&gt;name),true); } } if($flag) { Yii::app()-&gt;clientScript-&gt;scriptMap['jquery.js'] = false; $this-&gt;renderPartial('createDialog',array('model'=&gt;$model,),false,true); } } </code></pre> <p>file createDialog.php</p> <pre><code>&lt;?php $this-&gt;beginWidget('zii.widgets.jui.CJuiDialog',array( 'id'=&gt;'institutionDialog', 'options'=&gt;array( 'title'=&gt;Yii::t('institution','Institution'), 'autoOpen'=&gt;true, 'modal'=&gt;'true', 'width'=&gt;'auto', 'height'=&gt;'auto', ), )); echo $this-&gt;renderPartial('_formDialog', array('model'=&gt;$model)); ?&gt; &lt;?php $this-&gt;endWidget('zii.widgets.jui.CJuiDialog');?&gt; </code></pre> <p>and finally a piece from the _formDialog.php</p> <pre><code> &lt;div class="form" id="institutionDialogForm"&gt; &lt;?php $form=$this-&gt;beginWidget('CActiveForm', array( 'id'=&gt;'institution-form', 'enableAjaxValidation'=&gt;true, )); ?&gt; &lt;?php echo $form-&gt;errorSummary($model); ?&gt; &lt;div class="row"&gt; &lt;?php echo $form-&gt;labelEx($model,'name'); ?&gt; &lt;?php echo $form-&gt;textField($model,'name',array('size'=&gt;60,'maxlength'=&gt;255)); ?&gt; &lt;?php echo $form-&gt;error($model,'name'); ?&gt; &lt;/div&gt; .... &lt;div class="row buttons"&gt; &lt;?php echo CHtml::ajaxSubmitButton(Yii::t('institution','Create'),CHtml::normalizeUrl(array('institution/addnew','render'=&gt;false)),array('success'=&gt;'js: function(data) { $("#User_institutionid").append(data); $("#institutionDialog").dialog("close"); }'),array('id'=&gt;'closeInstitutionDialog')); ?&gt; &lt;/div&gt; &lt;?php $this-&gt;endWidget(); ?&gt; &lt;/div&gt; </code></pre> <p>Any idea? in this example I would like that the "name" that is already set as required on the rules to be required here as well. Note that on the default crud files that gii generates this is working ok. And I'm trying to implement a wizard with modal windows to add new itens while filling the wizards.</p> <p>To be more clear, I would like to avoid submitting the modal window so that the required field(s) are asked to be filled before hitting the submit buttom on the modal window.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload