Select Sql Query Manipulation (Multiple Combo option in Zend)

Asked

Viewed 32 times

0

Good morning,

I have a "Select" that lists as an option everything in the table "areas", followed by the word "ALL",

Below each "area" option are listed those sub-areas that link to the area.

When you click on "all - areas", then select automatically understands how all subareas, and selects them correctly.

Is working,

The problem occurs when there are no subareas and then the name of the area followed by "- all",

The user selects this option and does not understand why it does not work, but it is because there are no sub-areas,

I need to hide this option, for when there are no sub-areas, but I don’t know what part of the code makes the modification.

Why in the second part, where it shows the sub-areas within the area, then already listed the paavra "area - all".

the code is

private function getComboBoxGroup ()
{
    $group = [ ];

    foreach ( $this->getAreasTable ()->fetchAll () as $area ) {
        $group[$area->__get ( 'f_name' )] = [
            'label'     => $area->__get ( 'f_name' ),
            'data-area' => $area->__get ( 'f_id' ),
            'options'   => [ "ALL - {$area->__get ( 'f_name' )}" => "TODAS - {$area->__get ( 'f_name' )}" ]
        ];
    }

    foreach ( $this->getActionsTypesTable ()->fetchAll () as $action ) {

        if ( array_key_exists ( $action->__get ( 'f_area' ), $group ) ) {
            $group[$action->__get ( 'f_area' )]['options'][$action->__get ( 'f_id' )] =
                "[{$action->__get ( 'f_area' )}] " . $action->__get ( 'f_name' );

        }

    }

    return $group;
}

1 answer

0

Try to check the data

'options'   => [ "ALL - " . !empty($area->__get('f_name')) ? $area->__get ( 'f_name' ) : "alguma coisa" => "TODAS - " . !empty($area->__get ( 'f_name' ))? $area->__get ( 'f_name' ) : "alguma coisa" ]

Browser other questions tagged

You are not signed in. Login or sign up in order to post.