I have a custom component,
One of my xml form fields has multiple=true
It gives me the ability to select more than one item from another table via an sql query
However...
I can not work out how to insert it?
protected function loadFormData(){
$app = JFactory::getApplication();
$data = $app->getUserState('tourbookings.edit.tour.data', array());
if(empty($data)){
$data = $this->getItem();
// i added this but no luck
$data->itinerary = explode(',', $data->itinerary);
var_dump($data);
if($this->getState('tour.id') == 0){
$data->set('catid', $app->input->getInt('catid', $app->getUserState('com_tourbookings.tours.filter.category_id')));
}
}
return $data;
}
My var_dump looks like this:
object(JObject)#169 (32) {
["_errors":protected]=> array(0) { }
["id"]=> string(1) "2"
["itinerary"]=> array(2) { [0]=> string(1) "1" [1]=> string(1) "2" }
}
If anyone could help shed light on this i would be grateful :)
note: Joomla provides simple docs on how to create the xml form fields for a custom component but its not so cl;ear how to insert arrays from select lists etc..
My xml that produces a field that lets me select more than one value
<field
name="itinerary"
type="sql"
label="Itinerary"
description="COM_TOURBOOKINGS_TOURS_FIELD_ITINERARY_DESC"
size="40"
query="SELECT id AS value, name FROM #__bs_itinerarys"
key_field="value"
value_field="name"
translate="0"
onList="1"
onForm="1"
required="0"
multiple="1"
validate=""
class="input"
/>
cheers Jonny