Layne, on 07 July 2012 - 09:09 AM, said:
Your function must return true if you want to continue submission or false - to prevent it.
Your code can look like this:
Thank you for your response =).
I m newbie with jQuery too :s.
But here what i did:
I have 2 forms the first is a simple form that have a multiple input fields
<?php $form=$this->beginWidget('CActiveForm', array(
The second is for uploading files:
<?php $formUpload=$this->beginWidget('CActiveForm', array(
'htmlOptions' => array('enctype' => 'multipart/form-data')
Now I want to create a new record for the first form before uploading the file. So when a user filled the first form && upload relative files it will create a new record for the first form and create an other new record for the upload form (the first form and upload are two separated ActiveRecord related by a foreign key).
<?php $js = <<< EOF_JS
var FirstForm= document.getElementById('first-form');
var UploadsForm = document.getElementById('uploads-form');
UploadsForm.elements["Title"].value = FirstForm.elements["Title"].value; .....
Yii::app()->clientScript->registerScript('uploads-form-beforeValidate', $js, CClientScript::POS_READY);
NOW I WANT TO RUN THIS JS FUNCTION BEFORE SUBMITING to get information from the first form and passe them in to the hidden input !
My submit button is
<div class="row buttons">
array('submit' => array('controller/action'))
SO HOW CAN I DO IT ?