Get it using getValue ()
$type->getValue();
This will be an array with ONLY elements that have been checked.
i.e
<input type="checkbox" name="type[]" id="campaign_id" value="1" />
<input type="checkbox" name="type[]" id="campaign_id" value="2" />
will return such an array (if both checkboxes are checked)
Array
(
[0] => 1
[1] => 2
)
if it is indicated that only flag 2 has been checked, the array will be
Array
(
[0] => 2
)
If unchecked, getValue () will return NULL
source
share