Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6255487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T14:22:28+00:00 2026-05-24T14:22:28+00:00

I have a task form for an application I am building which allows me

  • 0

I have a task form for an application I am building which allows me to specify what contact it is assigned to. I had set up a dependent dropdown in Yii with the following code:

echo $form->dropDownList($model,'associationType',
array('none'=>'None','contact'=>'Contact','sale'=>'Sale','account'=>'Account',
'project'=>'Project','case'=>'Case'),
                    array(
                        'ajax' => array(
                            'type'=>'POST', //request type
                            'url'=>CController::createUrl('tasks/parseType'), //url to call.
                            //Style: CController::createUrl('currentController/methodToCall')
                            'update'=>'#auto_complete', //selector to update
                            )
                    ));

What I’m trying to do is use the CJuiAutoComplete widget with the dropDown specifying which array to grab. So the drop down is selected to contacts, it should get a list of contacts etc.

Here is what I have for the CJui widget

$this->widget('zii.widgets.jui.CJuiAutoComplete', array(
                'name'=>'auto_select',
                'source' => $names,
                'options'=>array(
                    'minLength'=>'2',
                    'select'=>'js:function( event, ui ) {
                        $("#'.CHtml::activeId($model,'associationId').'").val(ui.item.id);
                        return false;
                    }',
                ),
            ));

The variable $names is just a placeholder for now, but in my controller method I pass it a JSON encoded array with id and name. Controller code:

public function actionParseType() {
            //if(isset($_POST['TaskChild']['associationType'])){
                //$type=$_POST['TaskChild']['associationType'];
                $type='sale';
                $sql = 'SELECT id, name FROM x2_'.$type.'s';
                $cmd = Yii::app()->db->createCommand($sql);
                $res = $cmd->queryAll();

                echo CJSON::encode($res);

            //}
}

Right now I’m forcing it to use “Sale” but I don’t get anything when I call the method, and was wondering how I might go about fixing this. I’m still a little new to Yii so I’ve been mostly reading wiki/forum posts on how these kinds of thing are done. Any help is greatly appreciated, thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T14:22:29+00:00Added an answer on May 24, 2026 at 2:22 pm

    Try something like this in your controller action:

        $sql = 'SELECT people_id as id, CONCAT(first_name," ",last_name) as value, first_name as label FROM people WHERE first_name LIKE :qterm ORDER BY first_name ASC';
        $command = Yii::app()->db->createCommand($sql);
        $qterm = $_GET['term'].'%';
        $command->bindParam(":qterm", $qterm, PDO::PARAM_STR);
        $result = $command->queryAll();
        echo CJSON::encode($result); exit;
    

    Then you can check it by using this in your widget ‘options’ array: 'select'=>'js:function(event, ui) { console.log(ui.item.id +":"+ui.item.value); }'

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Windows Form Application in which clicking certain buttons create objects from
I have a windows application which has three forms : Form1,2,3. --Form 1, has
Suppose, I have the following task. There is a main application form with numerous
I have an object Task and a form that saves it. I want to
I have run into a case where a Windows Form application is being run
I have single-thread windows form application written with VB.NET and targeting Framework 1.1 .
I have a binary application on windows (train timetable software) which contains a lot
I have created a form application in VC++ and developed a deployment setup. We
I have a Microsoft Access form which will display a Microsoft Word app with
I have written an application (using Delphi 2009) that allows a user to select

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.