Hi All,
I got a problem regarding the republishing of dynamically generated dropdowns and the ChronoForms content plugin.
I have created a ChronoForm where I have 15 dropdowns all containing the same values (numbers from 1-60). Due to I did not want to copy the code for these 60 equal options over and over again, I utilized Joomla's outstanding framework to do the job for me.
The code is as follows:
Please note that I could have used JHTML::_('select.integerlist') for the example instead of creating a "drawOptions()" function but the type of the dropdown doesn't matter in this case.
As you can see, I also created a custom republish function to republish the dynamic dropdowns.
The thing is that this function actually works as long as I call the form directly (using index.php?option=com_chronocontact&chronoformname=FORMNAME) but it doesn't when I include the form in an article using the ChronoForms content plugin (Syntax: {chronocontact}FORMNAME{/chronocontact}).
One thing I noticed during revealing this behavior is that when you call the form directly and print the $_POST values (using print_r($_POST);), this piece of code returns all the posted values. By using the content plugin, it simply returns an empty array. I think that these two things are connected two eachother as my custom republish function needs the $_POST values to correctly display the selected value.
Can anybody please help and maybe tell me how to republish dynamically generated dropdowns?
The ChronoForms republish function works exceptionally with static (= non-dynamic) dropdowns, btw ...
I'm using Joomla! 1.5.17 together with the ChronoForms component Version 3.1 RC5.2 and the ChronoForms plugin Version 3.1 RC5.2
Any help is greatly appreciated.
Thank you very much in advance!
Cheers,
Eric
I got a problem regarding the republishing of dynamically generated dropdowns and the ChronoForms content plugin.
I have created a ChronoForm where I have 15 dropdowns all containing the same values (numbers from 1-60). Due to I did not want to copy the code for these 60 equal options over and over again, I utilized Joomla's outstanding framework to do the job for me.
The code is as follows:
<?php
// function for generating the dropdowns
function drawOptions($number=60) {
$personen = array();
for($i=0; $i<=$number; $i++) {
$personen[] = JHTML::_('select.option', $i, $i.' ');
}
return $personen;
}
// function to republish the values of the generic dropdowns
function republishValue($fieldname) {
// dropdowns only contain numeric values so let's use the getInt() function to get the integers
if(JRequest::getInt($fieldname, '', 'post')) return JRequest::getInt($fieldname, '', 'post');
else return '0';
}
echo JHTML::_('select.genericlist', drawOptions(), 'adults', 'class="inputbox"', 'value', 'text', republishValue('adults'));
?>
Please note that I could have used JHTML::_('select.integerlist') for the example instead of creating a "drawOptions()" function but the type of the dropdown doesn't matter in this case.
As you can see, I also created a custom republish function to republish the dynamic dropdowns.
The thing is that this function actually works as long as I call the form directly (using index.php?option=com_chronocontact&chronoformname=FORMNAME) but it doesn't when I include the form in an article using the ChronoForms content plugin (Syntax: {chronocontact}FORMNAME{/chronocontact}).
One thing I noticed during revealing this behavior is that when you call the form directly and print the $_POST values (using print_r($_POST);), this piece of code returns all the posted values. By using the content plugin, it simply returns an empty array. I think that these two things are connected two eachother as my custom republish function needs the $_POST values to correctly display the selected value.
Can anybody please help and maybe tell me how to republish dynamically generated dropdowns?
The ChronoForms republish function works exceptionally with static (= non-dynamic) dropdowns, btw ...
I'm using Joomla! 1.5.17 together with the ChronoForms component Version 3.1 RC5.2 and the ChronoForms plugin Version 3.1 RC5.2
Any help is greatly appreciated.
Thank you very much in advance!
Cheers,
Eric