Note that there are some explanatory texts on larger screens.

plurals
  1. POValidating a Form without redirect
    primarykey
    data
    text
    <p>I created app with yii and I need to load a view form in Fancy-box.<br> I did that but my problem is when I click on the submit button the form redirects me to the controller action without validating the form. </p> <p>How to validate the form without the redirect inside Fancy-box?</p> <p>My view:</p> <pre><code>&lt;?php $config = array( ); $this-&gt;widget('application.extensions.fancybox.EFancyBox', array( 'target'=&gt;'#getaction', 'config'=&gt;$config,)); echo CHtml::link('Add Section',array('section/create'),array('id'=&gt;'getaction')); ?&gt; </code></pre> <p>FormView _from from call from another view </p> <pre><code>&lt;div class="form"&gt; &lt;?php $form=$this-&gt;beginWidget('CActiveForm', array( 'id'=&gt;'section-form', 'enableAjaxValidation'=&gt;true, )); ?&gt; &lt;p class="note"&gt;Fields with &lt;span class="required"&gt;*&lt;/span&gt; are required.&lt;/p&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::submitButton($model-&gt;isNewRecord ? 'Create' : 'Save'); ?&gt; &lt;/div&gt; &lt;?php $this-&gt;endWidget(); ?&gt; &lt;/div&gt;&lt;!-- form --&gt; </code></pre> <p>Controller :</p> <pre><code>public function actionCreate() { $model=new Section; if(isset($_POST['Section'])) { $model-&gt;attributes=$_POST['Section']; if($model-&gt;validate()) //// Do Som code here $this-&gt;redirect(array('view','id'=&gt;$model-&gt;id)); } $this-&gt;render('create',array( 'model'=&gt;$model, )); } </code></pre>
    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.
 

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