I would like to know how to get parent terms only, for example “Ages 0-2” and also print in dropdown.
This is the structure of the form array.
Array(
[#info] => Array(
[filter-tid] => Array(
[operator] => tid_op
[value] => tid
[label] => Term
[description] =>
)
)
[tid] => Array(
[#type] => select
[#options] => Array(
[All] => - Any -
[0] => stdClass Object(
[option] => Array(
[367] => Ages 0-2
)
)
[1] => stdClass Object(
[option] => Array(
[2378] => -Infant
)
)
)
)
)
This is the code I am using.
if ($form['#id']== "views-exposed-form-quick-find") {
$test = $form['tid']['#options'];
foreach ($test as $tid) {
// It prints "Array" and the "Trying to get property of non-object" message.
print $tid->option;
}
}
I do not understand why the “Array” text repeats; it could be I am not pointing to right array.
How do I remove all children which do not have “age 12 – 14” (see “-” in the middle not from start)?