Dynamic Data Drop Down

Xzerod 12 Aug, 2014
Hi, in your FAQ you wrote:


Dynamic Data from a database table
You can use the ChronoForms DB Multi Record Loader action (or the DB Read action in CFv5) 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.


ok, i've set the Model ID to 'verein'


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.



in Chronoforms V5 (don't know if this FAQ was written for V4), i can enable the dynamic data and have to set a data path! (i tried 'verein' and $myform->verein but nothing works).

Formname: Spieleintragung
Designer Element Settings:
Fieldname & Fieldid: heimverein
Dynamic Data
- Enabled: yes
- Datapath: verein
- Value key: id
- Text key: name

Setup -> Onload (DB Read before my HTML Renderform & Debugger)
Enabled: yes
Tablename: #__vereine
Multiread: yes (?)
Enable Model ID: yes
Model ID: verein
Fields: id, name

Debug-Output:

Data Array

Array
(
    [option] => com_chronoforms5
    [chronoform] => Spieleintragung
    [verein] => Array
        (
            [0] => Array
                (
                    [id] => 1
                    [name] => 1. FC Grev
                )

            [1] => Array
                (
                    [id] => 2
                    [name] => BV Weck
                )

            [2] => Array
                (
                    [id] => 3
                    [name] => BV Wev
                )
[...]


Tried many settings but nothings works. I've searched for help in your forum and got many Threads where this problem was asked but not directly answered.

please check your faq and update this for your actually version so nobody has to ask for this - maybe easy - problem anymore.

Thanks
Xzerod 14 Aug, 2014
Answer
Sorry for the double post.

i changed from wizard to custom form and did this dynamic data from datatable with following code lines


			<select name="gastVerein" class="form-control" id="gastVerein">
				<?php
					$options = array();
					$options[] = "<option value=''>...</option>";
					$db =& JFactory::getDBO();
					$query = "
						SELECT `id`, `name`
						FROM `#__vereine`
						ORDER BY `id`;
					";
					$db->setQuery($query);
					$data = $db->loadObjectList();
					foreach ( $data as $d ) {
						$options[] = "<option value='{$d->id}'>{$d->name}</option>";
					}
					echo implode("\n", $options);
				?>
			</select>


I really don't know yet how to set the wizard settings but for all who have the same problems - this is one solution
Max_admin 14 Aug, 2014
Hi Xzerod,

Your settings should work fine on CFv5 if you have the latest update, earlier releases had a small glitch!

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Xzerod 15 Aug, 2014
Hi Max,
i downloaded the latest version just three days ago and there is no further update shown.
I really don't know whats going wrong but please check your faq and update the explanation for CFv5

Thanks
Max_admin 18 Aug, 2014
I have just tested this and it works fine, a demo form will be included in the next update!

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.