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).
To do that I create a javascript function that copied information filled in the first form to a hidden input on upload form.
<?php $js = <<< EOF_JS
function copyFirstFormToUploadsForm(){
var FirstForm= document.getElementById('first-form');
var UploadsForm = document.getElementById('uploads-form');
UploadsForm.elements["Title"].value = FirstForm.elements["Title"].value; .....
}
EOF_JS;
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 !