Hello,
I have some data imported into a Joomla table from Salesforce that includes a couple of multiselect fields. The separator is a semicolon ";".
I wanted to have the DB Record loader populate a multiselect dropdown in a Chronoform, so I placed the field name in the Array Field set and a ; in the Array Separator set. This successfully displayed the first selected item, but not the others.
Then I noticed that in the imported data there is a space: the incoming field contains "Item1; Item2; Item3". Since the dropdown list doesn't have the spaces, they don't select. I manually edited the field using phpMyAdmin to remove the spaces on one row and then they match and select.
However there are thousands of rows with arrays like the above, and I have no control over the export of this data
Is there any way to put a value like "; " <semicolon + space>" in the Array separator field of the DB record loader? I have tried this in the simple way by just entering the space but it doesn't work.
A workaround is to manipulate the data before importing but I would prefer to avoid this as it is an automated import.
Cheers
Tim
I have some data imported into a Joomla table from Salesforce that includes a couple of multiselect fields. The separator is a semicolon ";".
I wanted to have the DB Record loader populate a multiselect dropdown in a Chronoform, so I placed the field name in the Array Field set and a ; in the Array Separator set. This successfully displayed the first selected item, but not the others.
Then I noticed that in the imported data there is a space: the incoming field contains "Item1; Item2; Item3". Since the dropdown list doesn't have the spaces, they don't select. I manually edited the field using phpMyAdmin to remove the spaces on one row and then they match and select.
However there are thousands of rows with arrays like the above, and I have no control over the export of this data
Is there any way to put a value like "; " <semicolon + space>" in the Array separator field of the DB record loader? I have tried this in the simple way by just entering the space but it doesn't work.
A workaround is to manipulate the data before importing but I would prefer to avoid this as it is an automated import.
Cheers
Tim
Hi Tim,
It should work fine if you add a space (e.g: "; ") in the db record loader, but if it doesn't then you can simply add this code to a custom code action after the "db record loader":
Regards,
Max
It should work fine if you add a space (e.g: "; ") in the db record loader, but if it doesn't then you can simply add this code to a custom code action after the "db record loader":
<?php
$form->data["field"] = explode("; ", $form->data["field"]);
Regards,
Max
Thanks Max
Putting the space after the separator in the DB Loader didn't work for some reason, however the custom code did - almost!
The data in the incoming string looks like: "Item1; Item2". The explode picks up Item2 but not Item1. If I add a separator before the first item then it works but that is not a good solution because I don't want to modify the incoming data.
I thought explode would take the first element and place it in field[0] but apparently not.
Putting the space after the separator in the DB Loader didn't work for some reason, however the custom code did - almost!
The data in the incoming string looks like: "Item1; Item2". The explode picks up Item2 but not Item1. If I add a separator before the first item then it works but that is not a good solution because I don't want to modify the incoming data.
I thought explode would take the first element and place it in field[0] but apparently not.
Hi Tim,
Yes, explode should add the first item as well, please try to add this line after the line above:
You don't get the 2 items ?
Regards,
Max
Yes, explode should add the first item as well, please try to add this line after the line above:
print_r2($form->data["field"]);
You don't get the 2 items ?
Regards,
Max
Thanks Max,
OK, the explode works - the print shows an item in both field[0] and field[1] as expected.
However only the second item is selected in the multiselect list.
Very strange.
OK, the explode works - the print shows an item in both field[0] and field[1] as expected.
However only the second item is selected in the multiselect list.
Very strange.
Could you please post the select element code here ? you can copy it from the code tab.
Regards,
Max
Regards,
Max
Here it is:
The incoming data string is "FRP; SteelTube". It selects and highlights only Steeltube.
There is a second multiselect dropdown that has the same behaviour. So whatever I am doing wrong, it is consistent🙂
Cheers
Tim
</select>
<div class="clear"></div><div id="error-message-Qualification_Achievement"></div></div><div class="ccms_form_element cfdiv_text" id="qualification_achievement_nbr1_container_div" style=""><label>Qual/Achevem't Nbr</label><input maxlength="150" size="30" class="" title="" type="text" value="" name="Qualification_Achievement_Nbr" />
<div class="clear"></div><div id="error-message-Qualification_Achievement_Nbr"></div></div><div class="ccms_form_element cfdiv_checkboxgroup" id="endorsed_structure_type_1_container_div" style=""><label>Structure Type</label><select multiple="multiple" size="4" class="" title="" name="Endorsed_Structure_Type[]">
<option value="None">None</option>
<option value="FRP">FRP</option>
<option value="Wood">Wood</option>
<option value="Metal">Metal</option>
<option value="SteelTube">SteelTube</option>
</select>
The incoming data string is "FRP; SteelTube". It selects and highlights only Steeltube.
There is a second multiselect dropdown that has the same behaviour. So whatever I am doing wrong, it is consistent🙂
Cheers
Tim
Hi Tim,
I suspect that it needs to be converted back to an array for the Republisher to use it (but I'm not certain of that).
Bob
I suspect that it needs to be converted back to an array for the Republisher to use it (but I'm not certain of that).
Bob
Thanks Bob,
I'm a bit puzzled - I thought the "explode" turned a string into an array? So how do I convert back to an array?
What is the "republisher" and how should I use it?
Sorry to be difficult with this but I am not very experienced with Chronoforms and I'm still learning PHP. Nearly everything works well for me, the products are great and your support is awesome - I am sure that this is a very easy thing once I get my head around it.
Cheers
Tim
I'm a bit puzzled - I thought the "explode" turned a string into an array? So how do I convert back to an array?
What is the "republisher" and how should I use it?
Sorry to be difficult with this but I am not very experienced with Chronoforms and I'm still learning PHP. Nearly everything works well for me, the products are great and your support is awesome - I am sure that this is a very easy thing once I get my head around it.
Cheers
Tim
Hi Tim,
I think that there is some hidden issue here, because we are back to the first point where the field is an array but the select is not republished, I'm not sure what's wrong, but you can send me the form link so I can check it myself.
Also please add a "debugger" action to the end of the "on load" event, does the data look as expected ? with an array value for this field ?
You may also try to replace the select (or just add a new field) by a "checkbox group", which should also allow multiple selections, check if this works better ?
Regards,
Max
I think that there is some hidden issue here, because we are back to the first point where the field is an array but the select is not republished, I'm not sure what's wrong, but you can send me the form link so I can check it myself.
Also please add a "debugger" action to the end of the "on load" event, does the data look as expected ? with an array value for this field ?
You may also try to replace the select (or just add a new field) by a "checkbox group", which should also allow multiple selections, check if this works better ?
Regards,
Max
This topic is locked and no more replies can be posted.
