Hello.
I'm new to chronoforms, but from what I have done till today, I think it's an excellent tool and can do many things with Joomla!
I have Joomla! 2.5 and I'm trying to build a form in which a guy must select some data an write new ones. Then (with custom code) I'll try to insert these data into DB as those data must be filed in more than one arrays in DB and must be some checks. I tried to do this with wizard (in preview tab) with the elements given but I couldn't populate the dropboxes. Is there any way of taking for example from DB table named "composers" the data "composer_id" and "composer_name" and putting them into the dropdown box? What should i put in MODEL ID? It confused me...
So I tried to accomplish it on my own. First I tried to populate the dropdown boxes with custom code on "On Load" event (on the events tab). Doing this, couldn't show me the elements.
So, I built my own custom code on "On Load" event with no elements on preview tab. My code for creating the elements (for my form) and populating them is as follows:
This creates the dropdown boxes and text boxes and populates them perfectly. It also shows the submit button.
After that I put the code below to take the data from the textbox "pdf_name" and tried to put it in the DB.
My problems are the following ones:
1) the form isn't cleared.
2) the data from the textbox aren't inserted into the DB.
Any suggestions?
Thanks in advance.
I'm new to chronoforms, but from what I have done till today, I think it's an excellent tool and can do many things with Joomla!
I have Joomla! 2.5 and I'm trying to build a form in which a guy must select some data an write new ones. Then (with custom code) I'll try to insert these data into DB as those data must be filed in more than one arrays in DB and must be some checks. I tried to do this with wizard (in preview tab) with the elements given but I couldn't populate the dropboxes. Is there any way of taking for example from DB table named "composers" the data "composer_id" and "composer_name" and putting them into the dropdown box? What should i put in MODEL ID? It confused me...
So I tried to accomplish it on my own. First I tried to populate the dropdown boxes with custom code on "On Load" event (on the events tab). Doing this, couldn't show me the elements.
So, I built my own custom code on "On Load" event with no elements on preview tab. My code for creating the elements (for my form) and populating them is as follows:
<div class="form_item">
<div class="form_element cf_dropdown">
<label class="cf_label" style="width: 150px;"> Όνομα Συνθέτη</label>
<select class="cf_inputbox validate-selection" id="cf_user_id" size="1" title="" name="cf_user_id">
<option value=""> Choose Composer</option>
<?php
$db =& JFactory::getDBO();
$query = "
SELECT *
FROM composer_names";
$db->setQuery($query);
$rows = $db->loadObjectList();
foreach ($rows as $row) {echo "<option value='$row->name_id'>$row->full_name</option>";}?>
</select>
</div>
</div>
<div class="form_item">
<div class="form_element cf_dropdown">
<label class="cf_label" style="width: 150px;"> Όνομα Έργου</label>
<select class="cf_inputbox validate-selection" id="cf_user_id" size="1" title="" name="cf_user_id">
<option value=""> Choose Composition</option>
<?php
$db =& JFactory::getDBO();
$query = "
SELECT *
FROM composition_names";
$db->setQuery($query);
$rows = $db->loadObjectList();
foreach ($rows as $row) {
echo "<option value='$row->composition_id'>$row->composition_name</option>";
}
?>
</select>
</div>
</div>
<div class="form_item">
<div class="form_element cf_textbox">
<label class="cf_label"
style="width: 150px;">Όνομα Αρχείου PDF</label>
<input class="cf_inputbox" maxlength="150" size="30"
title="" id="pdf_name" name="pdf_name" type="text" />
</div>
</div>
<div class="form_item">
<div class="form_element cf_textbox">
<label class="cf_label"
style="width: 150px;">Σχόλια</label>
<input class="cf_inputbox" maxlength="150" size="30"
title="" id="comments" name="comments" type="text" />
</div>
</div>
<div class="form_item">
<div class="form_element cf_textbox">
<label class="cf_label"
style="width: 150px;">Besetzung</label>
<input class="cf_inputbox" maxlength="150" size="30"
title="" id="Besetzung" name="Besetzung" type="text" />
</div>
</div>
<div class="form_item">
<div class="form_element cf_dropdown">
<label class="cf_label" style="width: 150px;"> Προέλευση Αρχείου</label>
<select class="cf_inputbox validate-selection" id="cf_user_id" size="1" title="" name="cf_user_id">
<option value=""> Choose Origin</option>
<?php
$db =& JFactory::getDBO();
$query = "
SELECT *
FROM composition_origin";
$db->setQuery($query);
$rows = $db->loadObjectList();
foreach ($rows as $row) {
echo "<option value='$row->origin_id'>$row->origin_name</option>";
}
?>
</select>
</div>
</div>
<div class="form_item">
<div class="form_element cf_dropdown">
<label class="cf_label" style="width: 150px;"> Κύκλος Έργου</label>
<select class="cf_inputbox validate-selection" id="cf_user_id" size="1" title="" name="cf_user_id">
<option value=""> Choose Cycle</option>
<?php
$db =& JFactory::getDBO();
$query = "
SELECT *
FROM composition_cycle";
$db->setQuery($query);
$rows = $db->loadObjectList();
foreach ($rows as $row) {
echo "<option value='$row->composition_cycle_id'>$row->composition_cycle_name</option>";
}
?>
</select>
</div>
</div>
<div class="form_item">
<div class="form_element cf_dropdown">
<label class="cf_label" style="width: 150px;"> Είδος Υλικού προς ψηφιοποίηση</label>
<select class="cf_inputbox validate-selection" id="cf_user_id" size="1" title="" name="cf_user_id">
<option value=""> Choose Digital Mat.</option>
<?php
$db =& JFactory::getDBO();
$query = "
SELECT *
FROM composition_digital_material";
$db->setQuery($query);
$rows = $db->loadObjectList();
foreach ($rows as $row) {
echo "<option value='$row->digi_material_id'>$row->digi_material_name</option>";
}
?>
</select>
</div>
</div>
<div class="form_item">
<div class="form_element cf_dropdown">
<label class="cf_label" style="width: 150px;"> Συλλογή</label>
<select class="cf_inputbox validate-selection" id="cf_user_id" size="1" title="" name="cf_user_id">
<option value=""> Choose Collection</option>
<?php
$db =& JFactory::getDBO();
$query = "
SELECT *
FROM compositions_collection";
$db->setQuery($query);
$rows = $db->loadObjectList();
foreach ($rows as $row) {
echo "<option value='$row->collection_id'>$row->collection_name</option>";
}
?>
</select>
</div>
</div>
<div class="form_item">
<div class="form_element cf_dropdown">
<label class="cf_label" style="width: 150px;"> Αρχείο Προέλευσης</label>
<select class="cf_inputbox validate-selection" id="cf_user_id" size="1" title="" name="cf_user_id">
<option value=""> Choose Archive</option>
<?php
$db =& JFactory::getDBO();
$query = "
SELECT *
FROM composition_archive";
$db->setQuery($query);
$rows = $db->loadObjectList();
foreach ($rows as $row) {
echo "<option value='$row->archive_id'>$row->archive_name</option>";
}
?>
</select>
</div>
</div>
<div class="form_item">
<div class="ccms_form_element cfdiv_submit" id="submit1_container_div" style="text-align:left"><input name="submit" class="" value="submit" type="submit" />
</div>
</div>
This creates the dropdown boxes and text boxes and populates them perfectly. It also shows the submit button.
After that I put the code below to take the data from the textbox "pdf_name" and tried to put it in the DB.
<?php
$pdf_name1 = $form->data['pdf_name'];
$db = &JFactory::getDBO();
$query = "INSERT INTO composition_pdf (pdf_name) VALUES ('$pdf_name1')";
$db->setQuery($query);
$db->query();
?>
My problems are the following ones:
1) the form isn't cleared.
2) the data from the textbox aren't inserted into the DB.
Any suggestions?
Thanks in advance.
Hi TilemahosG,
Please see this FAQ about populating checkboxes and drop-downs.
What do you mean by 'The form doesn't clear'?
The code for your DB Save should work OK provided that the Custom Code action is after the Upload Files action in your form. You can equally do the save using a DB Save action if you prefer.
If you add a Debugger action to the form On Submit event you will be able to see the data that is submitted.
Bob
Please see this FAQ about populating checkboxes and drop-downs.
What do you mean by 'The form doesn't clear'?
The code for your DB Save should work OK provided that the Custom Code action is after the Upload Files action in your form. You can equally do the save using a DB Save action if you prefer.
If you add a Debugger action to the form On Submit event you will be able to see the data that is submitted.
Bob
1) I have read this FAQ that you told me to, but I can't understand the section 'Data Path'
Data Path: the data to create the options needs to be in the $form->data[] array and this tells ChronoForms where to look for it.
It might have a simple model ID like 'my_option' if it is in the $form->data['my_option'] sub-array, or like 'my_options.aaa' if it is in the sub-sub array $form->data['my_options']['aaa']. The more complex model IDs are usually used with option data retrieved from a database table (see below).
If I have a table (in my DB) called 'x', how can I load 'id' and 'name' (for example) in the dropdown? I searched for this and I couldn't find it.
2) When I'm saying that the form doesn't clear, I mean that the form doesn't get cleared (the values in dropdown boxes and in textboxes aren't cleared).
3) The submit button seams not responding. It doesn't do anything (neither saving in DB, nor clearing the form, nor reloading the form.
What should I do?
Thanks again!
Data Path: the data to create the options needs to be in the $form->data[] array and this tells ChronoForms where to look for it.
It might have a simple model ID like 'my_option' if it is in the $form->data['my_option'] sub-array, or like 'my_options.aaa' if it is in the sub-sub array $form->data['my_options']['aaa']. The more complex model IDs are usually used with option data retrieved from a database table (see below).
If I have a table (in my DB) called 'x', how can I load 'id' and 'name' (for example) in the dropdown? I searched for this and I couldn't find it.
2) When I'm saying that the form doesn't clear, I mean that the form doesn't get cleared (the values in dropdown boxes and in textboxes aren't cleared).
3) The submit button seams not responding. It doesn't do anything (neither saving in DB, nor clearing the form, nor reloading the form.
What should I do?
Thanks again!
Any reply for my first question???
How can we load (dynamically) values (id & name) from a table called x in the DB in a dropdown box? What should I put on the field Data Path???
Thanks again!
How can we load (dynamically) values (id & name) from a table called x in the DB in a dropdown box? What should I put on the field Data Path???
Thanks again!
Hi TilemahosG,
Please read the next section in the FAQ called "Dynamic Data from a database table".
Bob
Please read the next section in the FAQ called "Dynamic Data from a database table".
Bob
I see.
I hadn't understood that I need a Multi Record Loader (first) for my DropDown Box.
I put them now (a Multi Record Loader before the showHTML action with all the fields needed written) and then use the Model ID, I put in the Multi Record Loader into the Dynamic Data of the DropDown Box (after I have enabled the DynamicData in Dropdown box). It still doesn't show anything.
Should I do something on the OnRecordFound action of the MultiRecordLoader in order to work my form? And what that should look like?
Thanks again!!!
I hadn't understood that I need a Multi Record Loader (first) for my DropDown Box.
I put them now (a Multi Record Loader before the showHTML action with all the fields needed written) and then use the Model ID, I put in the Multi Record Loader into the Dynamic Data of the DropDown Box (after I have enabled the DynamicData in Dropdown box). It still doesn't show anything.
Should I do something on the OnRecordFound action of the MultiRecordLoader in order to work my form? And what that should look like?
Thanks again!!!
OK I found my mistake!
It was really stupid!
I forgot to turn the 'Enable Data Displayer' to yes!!!
Thanks again very very much for the help!
It was really stupid!
I forgot to turn the 'Enable Data Displayer' to yes!!!
Thanks again very very much for the help!
This topic is locked and no more replies can be posted.