Hi everybody,
First of all, I apologize for my bad english.
Then, I work with Chronoforms V3.2 and have 2 problems:
1) I have an upload file field (named 'file_card') which has to be mandatory (or not) depending on the selected value of a dropdown list (named 'natio').
I mean that I have a dropdowslist, and if the selected value is 3 (id=3;value='Europeen'), the followed upload file field has to be required. If the selected value is not 3, the upload field has to NOT be required.
How can I do this?
2) When I want to edit a record, the upload field value not appears. And if I save without upload the file again, the value 'NOFILE' replace the previous one.
I have already done what mentionned here: http://www.chronoengine.com/forums.html?cont=posts&f=13&t=22791&p=74430&hilit=file+upload+required#p74430
and also here: http://chronoengine.com/forums.html?cont=posts&f=12&t=21682
but nothing seems to work with me.
Thank you very much for any help!!!
First of all, I apologize for my bad english.
Then, I work with Chronoforms V3.2 and have 2 problems:
1) I have an upload file field (named 'file_card') which has to be mandatory (or not) depending on the selected value of a dropdown list (named 'natio').
I mean that I have a dropdowslist, and if the selected value is 3 (id=3;value='Europeen'), the followed upload file field has to be required. If the selected value is not 3, the upload field has to NOT be required.
How can I do this?
2) When I want to edit a record, the upload field value not appears. And if I save without upload the file again, the value 'NOFILE' replace the previous one.
I have already done what mentionned here: http://www.chronoengine.com/forums.html?cont=posts&f=13&t=22791&p=74430&hilit=file+upload+required#p74430
and also here: http://chronoengine.com/forums.html?cont=posts&f=12&t=21682
but nothing seems to work with me.
Thank you very much for any help!!!
Nobody can help me ?
Pleeeeaaaase it is very important for me.
Thank you in advance.
Pleeeeaaaase it is very important for me.
Thank you in advance.
Hi novice75,
1) Is not simple. The validation library used in ChronoForms v3.2 makes it difficult to turn validation on and off. It is possible however and someone posted a solution here recently. It might be easier to add a custom JavaScript to show a message or enable/disable the Submit button.
2) You probably don't want a value to appear in the File Upload box when you edit the record? Unless this is cleared the form will try to upload the file again and it may not exist. Please think through the logic of this process.
You can add code in the OnSubmit Before Email box to check the submitted data and remove the NOFILE value if that is needed.
Bob
1) Is not simple. The validation library used in ChronoForms v3.2 makes it difficult to turn validation on and off. It is possible however and someone posted a solution here recently. It might be easier to add a custom JavaScript to show a message or enable/disable the Submit button.
2) You probably don't want a value to appear in the File Upload box when you edit the record? Unless this is cleared the form will try to upload the file again and it may not exist. Please think through the logic of this process.
You can add code in the OnSubmit Before Email box to check the submitted data and remove the NOFILE value if that is needed.
Bob
Thank you very much GreyHead for your answer.
1) I don't want to disabled the submit button but a message if the file haven't be uploaded could be a good solution. And that's why I have try to use this code in the Server Side validation Code box:
and also this:
But no one works. I feel that $_POST['file_card'] don't return any value (even if a file is uploaded)!! Indeed, all others values are well returned when I try with another variables (ex: $_POST['natio'] or $_POST['custom_name']...)but whith $_POST['file_card'], nothing is returned.
2) I have already try to put a code in the Onsubmit before email box:
or this:
but it didn't work. I feel again that $_POST['file_card'] doesn't return any value!!
What can I do??
1) I don't want to disabled the submit button but a message if the file haven't be uploaded could be a good solution. And that's why I have try to use this code in the Server Side validation Code box:
<?php
if(($_POST['file_card']=='NOFILE'))&&($_POST['natio']=='3'))
return 'Vous avez renseigné une nationalité européenne, vous devez donc télécharger le fichier.';
?>
and also this:
<?php
if(empty($_POST['file_card']))&&($_POST['natio']=='3'))
return 'Vous avez renseigné une nationalité européenne, vous devez donc télécharger le fichier.';
?>
But no one works. I feel that $_POST['file_card'] don't return any value (even if a file is uploaded)!! Indeed, all others values are well returned when I try with another variables (ex: $_POST['natio'] or $_POST['custom_name']...)but whith $_POST['file_card'], nothing is returned.
2) I have already try to put a code in the Onsubmit before email box:
<?php
$file_card= JRequest::getString('file_card', '', 'post');
if (!$file_card) {
unset($_POST['file_card']);
}
?>
or this:
<?php
$file_card= JRequest::getString('file_card', '', 'post');
if ($file_card== "NOFILE") {
unset($_POST['file_card']);
}
?>
but it didn't work. I feel again that $_POST['file_card'] doesn't return any value!!
What can I do??
2) Also when I try the onsubmit code before email unconditionally as suggested by Neil here :
http://www.chronoengine.com/forums.html?cont=posts&f=13&t=22791
so I did that:
But it didn't work neither.
http://www.chronoengine.com/forums.html?cont=posts&f=13&t=22791
so I did that:
<?php
unset($_POST['file_card']);
?>
But it didn't work neither.
Finally, for the second problem, I found my (stupid) mistake!!
The box "email the results" was set to 'NO', but I think that I have to set it at 'yes' even if I don't send email after the result...
However, the first problem remains:
Why the following code on the server side validation code box doesn't work with the upload file field??
I put this code in order to verify if the variable return something:
The result well returned $nationalite but nothing for the $fichier which always returned empty.
Here is the message displayed:'nationalité européenne fichier' and nothing then...
The box "email the results" was set to 'NO', but I think that I have to set it at 'yes' even if I don't send email after the result...
However, the first problem remains:
Why the following code on the server side validation code box doesn't work with the upload file field??
<?php
if(($_POST['file_card']=='NOFILE'))&&($_POST['natio']=='3'))
return 'Vous avez renseigné une nationalité européenne, vous devez donc télécharger le fichier.';
?>
I put this code in order to verify if the variable return something:
<?php
$fichier=$_POST['file_card'];
$nationalite=$_POST['natio'];
return 'nationalité'.$nationalite.'fichier'.$fichier;
?>
The result well returned $nationalite but nothing for the $fichier which always returned empty.
Here is the message displayed:'nationalité européenne fichier' and nothing then...
This topic is locked and no more replies can be posted.