Hi,
i'm starting with ChronoForms and i have a problem with a drop-down list.
I can save the content of a form, i can reload it to display but the selected options in drop-down are not selected. Values are well saved int he database.
Is somebody can help me, please ?
i'm starting with ChronoForms and i have a problem with a drop-down list.
I can save the content of a form, i can reload it to display but the selected options in drop-down are not selected. Values are well saved int he database.
Is somebody can help me, please ?
Hi castagnier ,
Which version of ChronoForms are you using? How are you re-loading the form data?
Please post a link to the form so we can take a quick look.
Bob
Which version of ChronoForms are you using? How are you re-loading the form data?
Please post a link to the form so we can take a quick look.
Bob
Hi greyhead,
we are testing version 4 on joomla 1.5.23. It's impossible to put a link to the form because it's installed on a local server for internal use only (sorry for that).
To reload the data we based our form on the tutorial DB_MULTI_RECORD_LOADER.
All fields are filled on the screen except combo box with no option selected back.
Do we need to use some extra code to put attribute "selected"=selected ?
What do you need more ?
we are testing version 4 on joomla 1.5.23. It's impossible to put a link to the form because it's installed on a local server for internal use only (sorry for that).
To reload the data we based our form on the tutorial DB_MULTI_RECORD_LOADER.
All fields are filled on the screen except combo box with no option selected back.
Do we need to use some extra code to put attribute "selected"=selected ?
What do you need more ?
Hi castagnier,
Please take a Form Backup using the icon in the Forms Manager and post it here (as a zipped file) or PM or email it to me and I'll take a closer look.
I just looked in the code for the DB Record Loader and that 'should' correctly set the value for a drop-down select box.
Bob
Please take a Form Backup using the icon in the Forms Manager and post it here (as a zipped file) or PM or email it to me and I'll take a closer look.
I just looked in the code for the DB Record Loader and that 'should' correctly set the value for a drop-down select box.
Bob
Bob,
i took a look in this tutorial but i see anything about combobox. Could you give me the chapter number.
I have attached the zip file to this post
thanks to take some times
i took a look in this tutorial but i see anything about combobox. Could you give me the chapter number.
I have attached the zip file to this post
thanks to take some times
We found that the problem is because we used a multiple select combobox.
When we uncheck "multiple", combobox is working correctly.
Do you know how we can manage a multi-select combobox ?
thanks in advance
When we uncheck "multiple", combobox is working correctly.
Do you know how we can manage a multi-select combobox ?
thanks in advance
Hi castagnier,
I don't have time to debug now as I'm about to go away for a few days.
The code is in components/com_chronoforms/libraries/includes/data_republish.php around line 142. You'll see a block marked // multi select. I can only imagine that there is a bug in those lines somewhere :-(
Bob
I don't have time to debug now as I'm about to go away for a few days.
The code is in components/com_chronoforms/libraries/includes/data_republish.php around line 142. You'll see a block marked // multi select. I can only imagine that there is a bug in those lines somewhere :-(
Bob
Thank you for your help,
finally, we think we found the solution
around line 150 in the module you specified, we have added a line with an explode to have an array
I hope this will help others
If you'd like to buy me a beer and to my colleague - then thank you very much
finally, we think we found the solution
around line 150 in the module you specified, we have added a line with an explode to have an array
foreach($matches_options[0] as $matches_option){
$pattern_value = '/value=("|\')(.*?)("|\')/i';
preg_match($pattern_value, $matches_option, $matches_value);
$optionmatch = $matches_option;
// added explode
$field_value = explode(',', $data[$field_name]);
// added explode
if(in_array($matches_value[2], $field_value)){
$optionmatch = preg_replace('/<option/i', '<option selected="selected"', $matches_option);
}
$selectmatch = str_replace($matches_option, $optionmatch, $selectmatch);
}
I hope this will help others
If you'd like to buy me a beer and to my colleague - then thank you very much
Hi all
Castagnier - thanks for your hack to data_republish.php (I make it after line 164) : this does enable multiple selections in a select box to be shown.
I also want to populate a checkbox group with multiple selections - this doesn't currently work. The code block for checkboxes around line 111 is different to the select box one, and while I get the general gist I'm nervous of performing surgery here.
Can someone advise what to change and exactly where please ?
Bob / Max - I've also populated the DB Record Loader options for array field sets & array separators in the wizard edit, but these don't have any effect for either select box or checkbox group multiple selections. Do I need to do anything else ?
Thanks
Steve
Castagnier - thanks for your hack to data_republish.php (I make it after line 164) : this does enable multiple selections in a select box to be shown.
I also want to populate a checkbox group with multiple selections - this doesn't currently work. The code block for checkboxes around line 111 is different to the select box one, and while I get the general gist I'm nervous of performing surgery here.
Can someone advise what to change and exactly where please ?
Bob / Max - I've also populated the DB Record Loader options for array field sets & array separators in the wizard edit, but these don't have any effect for either select box or checkbox group multiple selections. Do I need to do anything else ?
Thanks
Steve
Hi Steve,
Here's a fix for the checkbox group. This code block starts around line 98 in data_republish.php Note that I have removed a chunk of the existing code. The new version converts a string result into an array before processing. If there's a single selection it's a one-element array. This gets round the problem of detecting whether there are single or multiple values and whether a multiple selection is presented as a string or an array.
Bob
Here's a fix for the checkbox group. This code block starts around line 98 in data_republish.php Note that I have removed a chunk of the existing code. The new version converts a string result into an array before processing. If there's a single selection it's a one-element array. This gets round the problem of detecting whether there are single or multiple values and whether a multiple selection is presented as a string or an array.
//checkboxes or radios fields
$pattern_input = '/<input([^>]*?)type=("|\')(checkbox|radio)("|\')([^>]*?)>/is';
$matches = array();
preg_match_all($pattern_input, $html_code, $matches);
foreach ($matches[0] as $match) {
$pattern_value = '/value=("|\')(.*?)("|\')/i';
$pattern_name = '/name=("|\')(.*?)("|\')/i';
preg_match($pattern_name, $match, $matches_name);
preg_match($pattern_value, $match, $matches_value);
$field_name = str_replace('[]', '', $matches_name[2]);
$field_value = $this->fieldValue($matches_name[2], $data);
if ( !in_array($field_name, $skippedarray) && !empty($field_value) ) {
$namematch = $match;
// :: START FIX :: enable multiple selection
if ( !is_array($field_value) ) {
$field_value = explode(',', $field_value);
}
if(in_array($matches_value[2], $field_value)){
$namematch = preg_replace($this->_cfskipregex($pattern_name), 'name="${2}" checked="checked"', $match);
}
// :: END FIX ::
$html_code = str_replace($match, $namematch, $html_code);
}
}
Bob
This topic is locked and no more replies can be posted.