Here is my issue.
I've created a form in CFv5 and DB table 'mv2_publications' for it to store information about publications, its authors and conferences IDs those publications are related to. As for the conferences there was created a proper table "mv2_conferences".
Then i've created a connection with main model "Publication" in CCv5 due to this faq (http://chronoengine.com/faqs/72-ccv5/5208-connectivity-edit-with-chronoforms.html) in order my form would be opened through a connection view list to edit all necessary data.
So, here is my form fields with its names:
textbox - Publication[publication_title];
textbox - Publication[author_1] ... and 5 more fields like this one Publication[author_ 2] and so on;
dropdown - Publication[conf_id] - this field takes its names and values from DBRead action Model (as a result i have a dropdown list of conferences i wish to link my publication record to. The conferences data are stored in a DB table "mv2_conferences");
and, of course, i haven't forgot about
a hidden field - Publication[publ_id] - to store ID of currently edited publication record.
In my DB table "mv2_publications" i have all necessary fields:
publ_id
publication_title
author_1, ... , author_6
conf_id
My actions panel:
onLoad{
DBRead - for making Model for the dropdown- Publication[conf_id]
HTML(RenderForm)
}
onSubmit{
ConnectionAction
}
In described case with this set of actions and form elements all works perfect: the form is opened through through a connection view list of publications when i want to edit an existing record or save a new one into the DB.
The next step i wish to take is adding a file upload ability to my form. I want to upload publications files to the server and save their names in "mv2_publications" DB.
First, for this purpose i've added one more field to my DB and named it "fil".
Then i've inserted "Files Upload" action into onSubmit block just before ConnectionAction. Then i have changed its Files Config field value to Publication[fil]:doc.
I've added a new File Field element to my form an named it "Publication[fil]".
I've tested my form entered through the connection list view. As a result all entered was saved in DB except filename. Moreover the file was not uploaded to the server.
OK, i've changed Publication[fil] field name both in File Field and in Files Upload action simply to "fil". As a result the file was uploaded to the server (i found it in chronoforms default 'uploads' folder), but its name wasn't saved in database.
And that is my problem. I've read all the faqs and forum topics about the similar issue, but there were no topics about file upload with CFv5+CCv5 joint use and it seems to me i'm deadlocked.
Please, help me if you can. I would really appreciate.
Dynamic Data from a database table
You can use the ChronoForms DB Multi Record Loader (i've just used DBRead in CF5) action to create a data-set to use as your option list. You need to drag a copy of the action into the On Load event of your form and move it up before the Show HTML action. On the action General Tab you need to set at least the Table and Fields boxes (you may well need to complete others to select the records that you want to use).
For example, we might select the jos_content table and then add id,title in the Fields box. Note that the Model ID will default to josContent unless you set another value.
Save the action and go back on the Dynamic Data tab on the element. Enable the Dynamic Data; enter the Model ID josContent in the 'Model ID' box, then id in the 'value' box and title in the 'text' box.
Save the element and test the form, you should see a list of options that display the article titles as labels and return the matching article id when the form is submitted.
If you want to create a simple list where the value and label are the same you can just put title in both of the 'value' and 'text' boxes.
My Model has name "Data1" in DBRead action. And this name is entered in DataPath field of my dropdown element "Publication[conf_id]" setup panel.
thanks by so detailed explanation, if not i'd have been lost for sure ;-)
I got it working, do you think will be posible if you select with dropdown-tab a field 'title' (as you explain higher using both of the 'value' and 'text' boxes) to autofill another field 'id' (using your example) in another tab, its open me a lot of possibilities to edit tables and autofill records
Something like this:
jQuery(document).ready(function () {
jQuery('#dropdown_id').live("change", function () {
your code
});
});
<?php
$form->data["Publication"]["fil"] = $form->data["fil"]; ?>
And keep your current config as it is.
let me know if this can help you
you can read a database where you have to add information for example 2 new upload files
model id : publications
fields: id,file1,file2
conditions: <?php
return array('id' => $form->data("ID"));
?>
after that your custom code
<?php
if (isset($form->data['paper']['id'])) {
$form->data['publications']['file1']=$form->data['file1'];
$form->data['publications']['file2']=$form->data['file2'];
}
?>
and after datasave action
with model id : publications
Regards