Help with Editor cascading list syntax

Help with Editor cascading list syntax

PaulVickeryPaulVickery Posts: 10Questions: 3Answers: 0

Please can someone assist me. I have successfully got the example on the blog working, but I am now trying to add another parameter in the “where” clause.

Using the example below from the blog:

include_once( $_SERVER['DOCUMENT_ROOT']."/php/DataTables.php" );
$countries = $db
    ->select( 'country', ['id as value', 'name as label'], ['continent' => $_REQUEST['values']['continent']] )
echo json_encode( [
    'options' => [
        'country' => $countries
] );

I want to restrict the cascading Country list by have an “active” field so that I can ‘remove’ the options in the list , ie something like

[active => “Y” ].

I can get the above to work on its own but cannot combine it with

['continent' => $_REQUEST['values']['continent']]

Please can someone assist me with the syntax for "and where"


  • rf1234rf1234 Posts: 2,818Questions: 85Answers: 406

    If you replace the "select" method with Editor's "raw" method you are much more flexible. You can use regular SQL as you are probably used to.

    Here is an example from a getFormatter:

    ->getFormatter( function($val, $data, $opts) use ( $db ){
        $stmt = ('SELECT b.linked_ctr_id, a.serial, a.ctr_name
                    FROM ctr a  
              INNER JOIN ctr_has_ctr b ON = b.linked_ctr_id
                   WHERE b.ctr_id = :ctr_id 
                ORDER BY 1 ASC');  
        $result = $db ->raw()
        return $result->fetchAll(PDO::FETCH_ASSOC);
    } ),
  • allanallan Posts: 62,246Questions: 1Answers: 10,211 Site admin

    With the Database->select method, the third parameter is an array which is used for the condition. So you could use:

    $countries = $db
        ['id as value', 'name as label'],
          'continent' => $_REQUEST['values']['continent'],
          'active' => 'Y'


  • PaulVickeryPaulVickery Posts: 10Questions: 3Answers: 0

    Thank you both very much for your prompt responses. Alan, I have implemented your solution and it works perfectly, thank you.

Sign In or Register to comment.