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 8006571
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:33:22+00:00 2026-06-04T17:33:22+00:00

i tried the code from te source of Source Code i used for CJUIAutoComplete

  • 0

i tried the code from te source of

Source Code i used for CJUIAutoComplete

not getting where the mistake is
error showing as not authorised please help me i am new to Yii framework and for Debugging also.

Here goes my Error Log

2012/05/25 06:07:28 [error] [exception.CHttpException.403] exception 'CHttpException' with message 'You are not authorized to perform this action.' in C:\wamp\yii\framework\web\auth\CAccessControlFilter.php:157 

Stack trace:
#0 C:\wamp\yii\framework\web\auth\CAccessControlFilter.php(120) CAccessControlFilter->accessDenied(Object(CWebUser), 'You are not aut...')
#1 C:\wamp\yii\framework\web\filters\CFilter.php(39) CAccessControlFilter->preFilter(Object(CFilterChain))

#2 C:\wamp\yii\framework\web\CController.php(1146): CFilter->filter(Object(CFilterChain))
#3 C:\wamp\yii\framework\web\filters\CInlineFilter.php(59) CController->filterAccessControl(Object(CFilterChain))


#4 C:\wamp\yii\framework\web\filters\CFilterChain.php(131) CInlineFilter->filter(Object(CFilterChain))

#5 C:\wamp\yii\framework\web\CController.php(292): CFilterChain->run()

#6 C:\wamp\yii\framework\web\CController.php(266): CController->runActionWithFilters(Object(CInlineAction), Array)

#7 C:\wamp\yii\framework\web\CWebApplication.php(276): CController->run('autocompleteTes...')

#8 C:\wamp\yii\framework\web\CWebApplication.php(135): CWebApplication->runController('details/autocom...')

#9 C:\wamp\yii\framework\base\CApplication.php(162): CWebApplication->processRequest()

#10 C:\wamp\www\myapp\index.php(13): CApplication->run()

#11 {main}
REQUEST_URI=/myapp/index.php?r=details/autocompleteTest&term=asss
HTTP_REFERER=http://localhost/myapp/index.php?r=details/create

Controller Code is

<?php
class DetailsController extends Controller
{
/**
 * @var string the default layout for the views. Defaults to '//layouts/column2', meaning
 * using two-column layout. See 'protected/views/layouts/column2.php'.
 */
public $layout='//layouts/column2';

/**
 * @return array action filters
 */
public function filters()
{
    return array(
        'accessControl', // perform access control for CRUD operations
    );
}

    public function actionAutocompleteTest() {
$res =array();

if (isset($_GET['term'])) {
    $qtxt ="SELECT name FROM {{details}} WHERE name LIKE :username";
    $command =Yii::app()->db->createCommand($qtxt);
    $command->bindValue(":name", '%'.$_GET['term'].'%', PDO::PARAM_STR);
    $res =$command->queryColumn();
}

echo CJSON::encode($res);
Yii::app()->end();
}


/**
 * Specifies the access control rules.
 * This method is used by the 'accessControl' filter.
 * @return array access control rules
 */
public function accessRules()
{
    return array(
        array('allow',  // allow all users to perform 'index' and 'view' actions
            'actions'=>array('index','view'),
            'users'=>array('*'),
        ),
        array('allow', // allow authenticated user to perform 'create' and 'update' actions
            'actions'=>array('create','update'),
            'users'=>array('@'),
        ),
        array('allow', // allow admin user to perform 'admin' and 'delete' actions
            'actions'=>array('admin','delete'),
            'users'=>array('admin'),
        ),
        array('deny',  // deny all users
            'users'=>array('*'),
        ),
    );
}

/**
 * Displays a particular model.
 * @param integer $id the ID of the model to be displayed
 */
public function actionView($id)
{
    $this->render('view',array(
        'model'=>$this->loadModel($id),
    ));
}

/**
 * Creates a new model.
 * If creation is successful, the browser will be redirected to the 'view' page.
 */
public function actionCreate()
{
    $model=new Details;

    // Uncomment the following line if AJAX validation is needed
    // $this->performAjaxValidation($model);

    if(isset($_POST['Details']))
    {
        $model->attributes=$_POST['Details'];
        if($model->save())
            $this->redirect(array('view','id'=>$model->id1));
    }

    $this->render('create',array(
        'model'=>$model,
    ));
}

/**
 * Updates a particular model.
 * If update is successful, the browser will be redirected to the 'view' page.
 * @param integer $id the ID of the model to be updated
 */
public function actionUpdate($id)
{
    $model=$this->loadModel($id);

    // Uncomment the following line if AJAX validation is needed
    // $this->performAjaxValidation($model);

    if(isset($_POST['Details']))
    {
        $model->attributes=$_POST['Details'];
        if($model->save())
            $this->redirect(array('view','id'=>$model->id1));
    }

    $this->render('update',array(
        'model'=>$model,
    ));
}

/**
 * Deletes a particular model.
 * If deletion is successful, the browser will be redirected to the 'admin' page.
 * @param integer $id the ID of the model to be deleted
 */
public function actionDelete($id)
{
    if(Yii::app()->request->isPostRequest)
    {
        // we only allow deletion via POST request
        $this->loadModel($id)->delete();

        // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
        if(!isset($_GET['ajax']))
            $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
    }
    else
        throw new CHttpException(400,'Invalid request. Please do not repeat this request again.');
}

/**
 * Lists all models.
 */
public function actionIndex()
{
    $dataProvider=new CActiveDataProvider('Details');
    $this->render('index',array(
        'dataProvider'=>$dataProvider,
    ));
}

/**
 * Manages all models.
 */
public function actionAdmin()
{
    $model=new Details('search');
    $model->unsetAttributes();  // clear any default values
    if(isset($_GET['Details']))
        $model->attributes=$_GET['Details'];

    $this->render('admin',array(
        'model'=>$model,
    ));
}

/**
 * Returns the data model based on the primary key given in the GET variable.
 * If the data model is not found, an HTTP exception will be raised.
 * @param integer the ID of the model to be loaded
 */
public function loadModel($id)
{
    $model=Details::model()->findByPk($id);
    if($model===null)
        throw new CHttpException(404,'The requested page does not exist.');
    return $model;
}



/**
 * Performs the AJAX validation.
 * @param CModel the model to be validated
 */
protected function performAjaxValidation($model)
{
    if(isset($_POST['ajax']) && $_POST['ajax']==='details-form')
    {
        echo CActiveForm::validate($model);
        Yii::app()->end();
    }
}
}

Form Code

<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
    'id'=>'details-form',
    'enableAjaxValidation'=>false,
)); ?>

    <p class="note">Fields with <span class="required">*</span> are required.</p>

    <?php echo $form->errorSummary($model); ?>

    <div class="row">
        <?php echo $form->labelEx($model,'id'); ?>


        <?php echo $form->textField($model,'id'); ?>
        <?php echo $form->error($model,'id'); ?>
    </div>

    <div class="row">
        <?php echo $form->labelEx($model,'name'); ?>
        <?php $this->widget('zii.widgets.jui.CJuiAutoComplete', array(
    'name'=>'test1',
    'value'=>'test21',
    'source'=>$this->createUrl('details/autocompleteTest'),
    // additional javascript options for the autocomplete plugin
    'options'=>array(
            'showAnim'=>'fold',
    ),
));
    ?>
                <?php echo $form->error($model,'name'); ?>
    </div>

    <div class="row">
        <?php echo $form->labelEx($model,'phone'); ?>
        <?php echo $form->textField($model,'phone'); ?>
        <?php echo $form->error($model,'phone'); ?>
    </div>

    <div class="row">
        <?php echo $form->labelEx($model,'email'); ?>
        <?php echo $form->textField($model,'email'); ?>
        <?php echo $form->error($model,'email'); ?>
    </div>

    <div class="row buttons">
        <?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
    </div>

<?php $this->endWidget(); ?>

</div><!-- form -->

Thanks
Devendar

  • 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-06-04T17:33:25+00:00Added an answer on June 4, 2026 at 5:33 pm

    Try this its very simple for you..

    public function actionAutoCompleteLookup()
            {
               if(Yii::app()->request->isAjaxRequest && isset($_GET['q']))
               {
    
                  $name = $_GET['q']; 
    
                   $qtxt ="SELECT name FROM details WHERE name LIKE '%".$name."%'";
                   $command =Yii::app()->db->createCommand($qtxt);
    
                   $userArray =$command->queryColumn();
    
                  $returnVal = '';
                  foreach($userArray as $userAccount)
                  {
                     $returnVal .= $userAccount->getAttribute('first_name').'|'
                                                 .$userAccount->getAttribute('user_id')."\n";
                  }
                  echo $returnVal;
               }
            }
    

    And in the view code like this..

    <?php $this->widget('CAutoComplete',
              array(
                             //name of the html field that will be generated
                 'name'=>'name', 
                           //replace controller/action with real ids
                 'url'=>array('detail/AutoCompleteLookup'), 
                 'max'=>10, //specifies the max number of items to display
    
                             //specifies the number of chars that must be entered 
                             //before autocomplete initiates a lookup
    
                 ));
        ?>
    

    its work fine…

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

Sidebar

Related Questions

I've tried some tools for generate automatically class diagrams from the java source code
How do you or have tried to protect your source code repositories from commits
I tried the following code from w3schools. When I enter letters in a input
I tried to port code some from the FANN Lib (neuronal network written in
I tried following some of the code from here and here , but I
In my code i tried to connect signal from QTrayIcon object and my form
I'm trying to drop a SQL Server database from .NET code. I've tried using
i have tried this code to redirect a php page.but it s not working
For testing I used a Console application with the following source code: public string
I just tried to run the NAudio demos and I'm getting a weird error:

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.