I had the same problem with multi-select elements in the integrator but, after an hour or so, managed to come up with a solution, so thought I'd share ...
You'll have to edit the following file -
/administrator/components/com_breezingforms/libraries/crosstec/classes/BFIntegrate.php
Find the following:
| Code: |
public function field(array $data){
$this->data['data'.$data[_FF_DATA_ID]] = $data;
$i = 0;
foreach($this->rules As $rule){
$items = $this->getItems($rule['rule']->id);
$j = 0;
foreach($items As $item){
if($item->element_id == $data[_FF_DATA_ID]){
$this->rules[$i]['items'][$j]['item'] = $item;
$this->rules[$i]['items'][$j]['data'] = $data;
}
$j++;
}
$i++;
}
}
|
and change to:
| Code: |
public function field(array $data){
// check to see if element has already been processed
if(isset($this->data['data'.$data[_FF_DATA_ID]])) {
// if this is the first duplicate then create array
if(!isset($this->data_arrays)) $this->data_arrays = array();
// if this is the first duplicate of this element then make sure we've added an array keyed by element id
// and fill with first value found from the last pass
if(!isset($this->data_arrays[$data[_FF_DATA_ID]])) $this->data_arrays[$data[_FF_DATA_ID]][] = $this->data['data'.$data[_FF_DATA_ID]][_FF_DATA_VALUE];
// add current element value
$this->data_arrays[$data[_FF_DATA_ID]][] = $data[_FF_DATA_VALUE];
}
$this->data['data'.$data[_FF_DATA_ID]] = $data;
$i = 0;
foreach($this->rules As $rule){
$items = $this->getItems($rule['rule']->id);
$j = 0;
foreach($items As $item){
if($item->element_id == $data[_FF_DATA_ID]){
$this->rules[$i]['items'][$j]['item'] = $item;
// copy $data var so we don't change it
$tempdata = $data;
// if this element has been added as an array then use that as value
if(array_key_exists($item->element_id,$this->data_arrays)) $tempdata[_FF_DATA_VALUE] = $this->data_arrays[$item->element_id];
$this->rules[$i]['items'][$j]['data'] = $tempdata;
}
$j++;
}
$i++;
}
}
|
I've added comments which hopefully explain what's going on, although it's now almost 2am and I can barely see straight so it might not make much sense!
I suspect there might be a better way of doing this, although this seems to work and only requires one function change. Haven't done much testing though.
After making this code change, the '$value' variable in the integrator will turn into an array of values for multi-select elements.
Just use something like
| Code: |
if(is_array($value)) $value = implode(',',$value);
|
in the integrator code to add a comma separated list of values to your db.
Note: this won't affect form update criteria data, so don't use multi-selects for that.
Hope this helps,
Steve