$formModel->getElementData value to string

tiagovareta

Member
Hi,

I have a field (combobox), to select a phone number.
When calling the field value this way:
$number = $formModel->getElementData('tb_envio_sms_ind___sms_numero_enviar_sms_ind');

Returns the value of: "Array" and not the phone number I chose.

How can I resolve this situation?
 
Any element which is of the "element list" type (radio, dropdown, checkbox, database join, etc) is by definition an array.

If it's a single select (radio, single select dropdown) then you can safely assume the selection is the first and only item in the array, and just pop it ... although it's usually safer to make sure you got an array ...

Code:
$number = is_array($number) ? $number[0] : $number;

-- hugh
 
Any element which is of the "element list" type (radio, dropdown, checkbox, database join, etc) is by definition an array.

If it's a single select (radio, single select dropdown) then you can safely assume the selection is the first and only item in the array, and just pop it ... although it's usually safer to make sure you got an array ...

Code:
$number = is_array($number) ? $number[0] : $number;

-- hugh

Many thanks for the reply Cheesegrits!
Situation resolved :)
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top