CDD > Advanced > Eval Options code using $data or $formModel

Status
Not open for further replies.

pastvne

Bruce Decker
Porting and testing code from 3x to 4x and running into an issue on a CDD eval options PHP code set.

In 3.x I was able to (but probably should not have) done this:

Code:
$divisionCode = $data['csp_document_control___division_code_raw'];

It now seems that when I var_dump($data), it is null in this eval.
I was going to try to switch to $formModel but a var_dump of it also shows it is null.

Do I need to expose the $formModel myself in the eval code? If so, what instructions would cause $formData or $data to become visible? Or, more properly, how would I access a form value in the CDD Advanced > Eval Options PHP?
 
Last edited:
The only var that was previously available was $data. Can you change line 548 of plugins/fabnrik_element/cascadingdropdown/cascadingdropdown.php to the following:

Code:
if (Php::Eval(['code' => $eval, 'vars'=>['opt'=>$opt, 'data'=>$data]]) === false)

And let us know if that fixes it for you.
 
Additionally you should change your code to
$divisionCode = $data['csp_document_control___division_code_raw'] ?? ''; //or whatever default makes sense
to prevent " Debug: Caught exception on eval of CCD 0: Undefined array key" on form load
 
The only var that was previously available was $data. Can you change line 548 of plugins/fabnrik_element/cascadingdropdown/cascadingdropdown.php to the following:

Code:
if (Php::Eval(['code' => $eval, 'vars'=>['opt'=>$opt, 'data'=>$data]]) === false)

And let us know if that fixes it for you.

With that fix, the $data array is now exposed as it was in !F3. Many thanks... now back to testing!
 
Additionally you should change your code to
$divisionCode = $data['csp_document_control___division_code_raw'] ?? ''; //or whatever default makes sense
to prevent " Debug: Caught exception on eval of CCD 0: Undefined array key" on form load

Thank you Troester. I've made that change and will adopt it as best practice. Many thanks as always!
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top