Cannot unset group data

sales2010

Well-Known Member
Hello,

Please help me with this, i need to unset a hidden group in form based on selection made in a dropdown element. I tried to process the following code onBeforeProcess:

Code:
$solicitare = '{contracte_info_generale___tip_solicitare_raw}';
 
if ($solicitare[0] == 1 || $solicitare[0] == 2 || $solicitare[0] == 3 || $solicitare[0] == 5) {
unset($_REQUEST['join'][1508]);
 
}

The value for placeholder is correctly retrieved so i guess the problem is with the unset part

Same problem using $formModel->_formData, the data is still submited to database.

The odd part is that if i add this code to the php plugin in the form, the values for joined group are no longer displayed "after unset":


Code:
$foo = JRequest::getVar('contracte_as___alte_servicii_raw');
if ($foo[0] == '6') {
echo "<pre>before unset: ";print_r($_REQUEST);echo "</pre>";
unset($_REQUEST['join'][197]);
echo "<pre>after unset";print_r($_REQUEST);echo "</pre>";
}

Please tell me how can i do this for a non repeat group and also, for a repeat group?

Thank you
 
Try using the 'onBeforeStore' hook and unsettting via

Code:
unset($this->_formData['join'][197])
 
Can you re-paste the whole of your code, with the change Rob suggested?

I suspect the problem may be where you use a placeholder for $solicitare, then treat it as an array. Placeholders never expand to arrays, they are always string values.

So you might try:

PHP:
$solicitare = $formModel->getElementData('contracte_info_generale___tip_solicitare', true);

... which should get you the array you are expecting.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top