Yii Framework Forum: Yii Combobox Extension Not Working For Me - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Yii Combobox Extension Not Working For Me Rate Topic: -----

#1 User is offline   Sohail Abdul Khaliq 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 22
  • Joined: 29-August 12

Posted 16 September 2012 - 09:15 AM

hello all
i wanted to use a dropdownlist that has autocomplete functionalities.
so i googled and found a very nice yii extension EJuiComboBox from here.
http://www.yiiframew...ension/combobox
i downloaded it and copied combobox folder into the protected/extensions directory.

and in my view file i used the following code
<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'version-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,'VersionName'); ?>
		<?php echo $form->textField($model,'VersionName',array('size'=>50,'maxlength'=>50)); ?>
		<?php echo $form->error($model,'VersionName'); ?>
	</div>

<?php
$this->widget('ext.combobox.EJuiComboBox', array(
    'model' => $model,
    'attribute' => 'ModelID',
    // data to populate the select. Must be an array.
    'data' => $model->getAllModels(),
    // options passed to plugin
    // Options passed to the text input
    'options' => array(
        // JS code to execute on 'select' event, the selected item is
        // available through the 'item' variable.
        'onSelect' => 'alert("selected value : " + item.value);',
        // JS code to be executed on 'change' event, the input is available
        // through the '$(this)' variable.
        'onChange' => 'alert("changed value : " + $(this).val());',
        // If false, field value must be present in the select.
        // Defaults to true.
        'allowText' => false,
    ),
    // Options passed to the text input
    'htmlOptions' => array('size' => 10),
)); ?>






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

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

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


but when i view the page in the browser.i just shows the textbox.i used firebug to debug the page.i took

the screen shot.here it is
Attached File  pic.png (206.48K)
Number of downloads: 37
please tell me what im missing here.i want dropdownlist to be same as demo.here is the link to that.
http://jqueryui.com/...e/combobox.html
please guys its argent.
0

#2 User is offline   alirz23 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,090
  • Joined: 08-August 12
  • Location:Durban, South Africa

Posted 16 September 2012 - 03:31 PM

weird I have tested your code its works fine, make sure you have getAllModels() returning an array.
0

#3 User is offline   Sohail Abdul Khaliq 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 22
  • Joined: 29-August 12

Posted 17 September 2012 - 12:29 AM

View Postalirz23, on 16 September 2012 - 03:31 PM, said:

weird I have tested your code its works fine, make sure you have getAllModels() returning an array.


getAllModels() works just fine.if u look at the snap shot that i attached i shows all the option in <select> tag.
also i used a simple array like this

'data' => array('yii','is','fun','!'),

i copied it from here

http://www.yiiframew...ension/combobox

still does not work

please help me
0

#4 User is offline   bennouna 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,168
  • Joined: 05-January 12
  • Location:Morocco

Posted 17 September 2012 - 12:57 AM

Hi,

I also pasted your code on a fresh webapp generated by Yii 1.1.11 and it worked directly with 'data' => array('yii','is','fun','!'),

Don't you have any JS errors by any chance, and have you copied integrally the combobox folder (into your extensions folder) including its own 'assets' subfolder, containing 2 js files: jquery.ui.combobox.js, jquery.ui.widget.js, and jquery.ui.widget.min.js?

Also, you could try to empty your webroot/assets folder, it could work…

Good luck
0

#5 User is offline   Sohail Abdul Khaliq 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 22
  • Joined: 29-August 12

Posted 17 September 2012 - 01:32 AM

View Postbennouna, on 17 September 2012 - 12:57 AM, said:

Hi,

I also pasted your code on a fresh webapp generated by Yii 1.1.11 and it worked directly with 'data' => array('yii','is','fun','!'),

Don't you have any JS errors by any chance, and have you copied integrally the combobox folder (into your extensions folder) including its own 'assets' subfolder, containing 2 js files: jquery.ui.combobox.js, jquery.ui.widget.js, and jquery.ui.widget.min.js?

Also, you could try to empty your webroot/assets folder, it could work…

Good luck

thanks for the quick reply
im attaching my project hierarchy please take a look if im missing something
Attached File  hirarchy.png (20.69K)
Number of downloads: 13

thanks alot
0

#6 User is offline   bennouna 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,168
  • Joined: 05-January 12
  • Location:Morocco

Posted 17 September 2012 - 02:24 AM

It looks ok to me.

Don't you have any JS errors by any chance?

Please try to empty your webroot/assets folder, it could work… who knows!
0

#7 User is offline   Sohail Abdul Khaliq 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 22
  • Joined: 29-August 12

Posted 17 September 2012 - 09:54 AM

View Postbennouna, on 17 September 2012 - 02:24 AM, said:

It looks ok to me.

Don't you have any JS errors by any chance?

Please try to empty your webroot/assets folder, it could work… who knows!


i have deleted all the files from webroot/assets folder as you suggested.but its still not working.
can you send me the testing application that you created.i will be very thankful.
i will run that application to check whether the problem is with my app or im missing something

i will really appreciate that please
also i dont know how to check for js errors.i know a little about firebug but not much please help

thanks
0

#8 User is offline   bennouna 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,168
  • Joined: 05-January 12
  • Location:Morocco

Posted 17 September 2012 - 10:17 AM

To send the webapp would be an overkill I guess.

Here's what I did in simple steps:
  • Create a new webapp using yiic command
  • edit the protected/site/login.php file
  • paste your code, only the autocomplete part, and using the 'password' attribute
  • extract the combobox contents under protected/extensions


Edit: here's the edited login.php (successfully tested with 1.1.11)
<h1>Autocomplete demo</h1>

<div class="form">

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

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

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

<?php
$this->widget('ext.combobox.EJuiComboBox', array(
    'model' => $model,
    'attribute' => 'password',
    // data to populate the select. Must be an array.
    //'data' => $model->getAllModels(),
    'data' => array('yii','is','fun','!'),
    // options passed to plugin
    // Options passed to the text input
    'options' => array(
        // JS code to execute on 'select' event, the selected item is
        // available through the 'item' variable.
        'onSelect' => 'alert("selected value : " + item.value);',
        // JS code to be executed on 'change' event, the input is available
        // through the '$(this)' variable.
        'onChange' => 'alert("changed value : " + $(this).val());',
        // If false, field value must be present in the select.
        // Defaults to true.
        'allowText' => false,
    ),
    // Options passed to the text input
    'htmlOptions' => array('size' => 10),
)); ?>

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

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

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

0

#9 User is offline   Sohail Abdul Khaliq 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 22
  • Joined: 29-August 12

Posted 17 September 2012 - 10:33 AM

View Postbennouna, on 17 September 2012 - 10:17 AM, said:

To send the webapp would be an overkill I guess.

Here's what I did in simple steps:
  • Create a new webapp using yiic command
  • edit the protected/site/login.php file
  • paste your code, only the autocomplete part, and using the 'password' attribute
  • extract the combobox contents under protected/extensions


Edit: here's the edited login.php (successfully tested with 1.1.11)
<h1>Autocomplete demo</h1>

<div class="form">

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

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

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

<?php
$this->widget('ext.combobox.EJuiComboBox', array(
    'model' => $model,
    'attribute' => 'password',
    // data to populate the select. Must be an array.
    //'data' => $model->getAllModels(),
    'data' => array('yii','is','fun','!'),
    // options passed to plugin
    // Options passed to the text input
    'options' => array(
        // JS code to execute on 'select' event, the selected item is
        // available through the 'item' variable.
        'onSelect' => 'alert("selected value : " + item.value);',
        // JS code to be executed on 'change' event, the input is available
        // through the '$(this)' variable.
        'onChange' => 'alert("changed value : " + $(this).val());',
        // If false, field value must be present in the select.
        // Defaults to true.
        'allowText' => false,
    ),
    // Options passed to the text input
    'htmlOptions' => array('size' => 10),
)); ?>

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

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

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


sorry sir same problem but i managed to find something that could be the problem
i inspacted the page using google chrome and in the console tab i found this

Uncaught TypeError: Cannot call method 'add' of undefined jquery-ui.min.js:46
Uncaught TypeError: Object #<Object> has no method 'autocomplete' jquery.ui.combobox.js:11

please help
0

#10 User is offline   bennouna 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,168
  • Joined: 05-January 12
  • Location:Morocco

Posted 17 September 2012 - 11:20 AM

So it seems to be a JS problem. It can be many things: double registration of jQuery[-ui] can be a cause…

Anyway, for anyone reading and willing to help, which versions do you have for:
  • Yii
  • jQuery
  • jQuery-ui


Also, can you put you webapp online to see if someone can debug it?
0

#11 User is offline   Sohail Abdul Khaliq 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 22
  • Joined: 29-August 12

Posted 17 September 2012 - 12:30 PM

View Postbennouna, on 17 September 2012 - 11:20 AM, said:

So it seems to be a JS problem. It can be many things: double registration of jQuery[-ui] can be a cause…

Anyway, for anyone reading and willing to help, which versions do you have for:
  • Yii
  • jQuery
  • jQuery-ui


Also, can you put you webapp online to see if someone can debug it?


MY yii version is 1.1.12 i just downloaded it last week.i have not included any jquery or jquery-ui in my project.but i explored my asset folder and they exist in here (webroot/assets/f3401271/js/jquery-ui.min.js)
i open that file and at the very top it says jQuery UI 1.8.1
but i could not find my Jquery file anywhere
0

#12 User is offline   bennouna 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,168
  • Joined: 05-January 12
  • Location:Morocco

Posted 17 September 2012 - 01:58 PM

As I told you, I tested with Yii 1.1.11, maybe the extension author, or someone familiar with extension authoring, can help
0

#13 User is offline   bennouna 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,168
  • Joined: 05-January 12
  • Location:Morocco

Posted 17 September 2012 - 02:29 PM

I've just downloaded v 1.1.12 and did the same test, it works perfectly
0

#14 User is offline   Sohail Abdul Khaliq 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 22
  • Joined: 29-August 12

Posted 18 September 2012 - 09:53 AM

View Postbennouna, on 17 September 2012 - 02:29 PM, said:

I've just downloaded v 1.1.12 and did the same test, it works perfectly


sorry to bother you again sir.One last thing
i have uploaded a test application on this location

http://casper-yii.co...hp?r=site/login

please take a look at this login page for one last time.

i tried to use username field as a combobox for the test.but only textbox is display instead.

waiting for your reply
thanks
0

#15 User is offline   bennouna 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,168
  • Joined: 05-January 12
  • Location:Morocco

Posted 18 September 2012 - 11:48 AM

Hi,

There's something going wrong in your app. You say you have Yii 1.1.12? Fine, but how come, your jQuery is 1.4.2 (it should be 1.7.2) and jQuery-ui is 1.8.1 (should be 1.8.22) ?

Please see what's going on in your config and/or main layout.

Another thing, the standard Yii app doesn't register jquery.yiiactiveform.js
0

#16 User is offline   Sohail Abdul Khaliq 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 22
  • Joined: 29-August 12

Posted 19 September 2012 - 09:08 AM

View Postbennouna, on 18 September 2012 - 11:48 AM, said:

Hi,

There's something going wrong in your app. You say you have Yii 1.1.12? Fine, but how come, your jQuery is 1.4.2 (it should be 1.7.2) and jQuery-ui is 1.8.1 (should be 1.8.22) ?

Please see what's going on in your config and/or main layout.

Another thing, the standard Yii app doesn't register jquery.yiiactiveform.js


Hi
i dont understand.i just downloaded the latest framework last week and created the application. :(

here is the main layout file (webroot/protected/views/layouts/main.php)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="language" content="en" />

	<!-- blueprint CSS framework -->
	<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/screen.css" media="screen, projection" />
	<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/print.css" media="print" />
	<!--[if lt IE 8]>
	<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/ie.css" media="screen, projection" />
	<![endif]-->

	<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/main.css" />
	<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/form.css" />

	<title><?php echo CHtml::encode($this->pageTitle); ?></title>
</head>

<body>

<div class="container" id="page">

	<div id="header">
		<div id="logo"><?php echo CHtml::encode(Yii::app()->name); ?></div>
	</div><!-- header -->

	<div id="mainmenu">
		<?php $this->widget('zii.widgets.CMenu',array(
			'items'=>array(
				array('label'=>'Home', 'url'=>array('/site/index')),
				array('label'=>'About', 'url'=>array('/site/page', 'view'=>'about')),
				array('label'=>'Contact', 'url'=>array('/site/contact')),
				array('label'=>'Login', 'url'=>array('/site/login'), 'visible'=>Yii::app()->user->isGuest),
				array('label'=>'Logout ('.Yii::app()->user->name.')', 'url'=>array('/site/logout'), 'visible'=>!Yii::app()->user->isGuest)
			),
		)); ?>
	</div><!-- mainmenu -->

	<?php $this->widget('zii.widgets.CBreadcrumbs', array(
		'links'=>$this->breadcrumbs,
	)); ?><!-- breadcrumbs -->

	<?php echo $content; ?>

	<div id="footer">
		Copyright &copy; <?php echo date('Y'); ?> by My Company.<br/>
		All Rights Reserved.<br/>
		<?php echo Yii::powered(); ?>
	</div><!-- footer -->

</div><!-- page -->

</body>
</html>


and here is main config file (webroot/protected/config/main.php)
<?php

// uncomment the following to define a path alias
// Yii::setPathOfAlias('local','path/to/local-folder');

// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.
return array(
	'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
	'name'=>'My Web Application',

	// preloading 'log' component
	'preload'=>array('log'),

	// autoloading model and component classes
	'import'=>array(
		'application.models.*',
		'application.components.*',
		'application.extenstions.*',
	),

	// application components
	'components'=>array(
		'user'=>array(
			// enable cookie-based authentication
			'allowAutoLogin'=>true,
		),
		// uncomment the following to enable URLs in path-format
		/*
		'urlManager'=>array(
			'urlFormat'=>'path',
			'rules'=>array(
				'<controller:\w+>/<id:\d+>'=>'<controller>/view',
				'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
				'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
			),
		),
		*/
		'db'=>array(
			'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/testdrive.db',
		),
		// uncomment the following to use a MySQL database
		/*
		'db'=>array(
			'connectionString' => 'mysql:host=localhost;dbname=testdrive',
			'emulatePrepare' => true,
			'username' => 'root',
			'password' => '',
			'charset' => 'utf8',
		),
		*/
		'errorHandler'=>array(
			// use 'site/error' action to display errors
            'errorAction'=>'site/error',
        ),
		'log'=>array(
			'class'=>'CLogRouter',
			'routes'=>array(
				array(
					'class'=>'CFileLogRoute',
					'levels'=>'error, warning',
				),
				// uncomment the following to show log messages on web pages
				/*
				array(
					'class'=>'CWebLogRoute',
				),
				*/
			),
		),
	),

	// application-level parameters that can be accessed
	// using Yii::app()->params['paramName']
	'params'=>array(
		// this is used in contact page
		'adminEmail'=>'webmaster@example.com',
	),
);

i have not not done anything with these file for this application
0

#17 User is offline   bennouna 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,168
  • Joined: 05-January 12
  • Location:Morocco

Posted 19 September 2012 - 09:34 AM

Quote

i have not not done anything with these file for this application

I believe you, and neither did I. Why don't you re-download it or / and try again with a fresh webapp?
0

#18 User is offline   Sohail Abdul Khaliq 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 22
  • Joined: 29-August 12

Posted 19 September 2012 - 10:05 AM

View Postbennouna, on 19 September 2012 - 09:34 AM, said:

I believe you, and neither did I. Why don't you re-download it or / and try again with a fresh webapp?


HI
First of all i would like to Thank you for your time that you spend solving my problem.

as you suggested i downloaded the framework again and created a brand new app and extension worked like a charm

Thanks once again
0

#19 User is offline   paejan 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 11-October 10

Posted 11 October 2012 - 10:57 PM

I have problem with my combobox.. the list box not populate.. only the textfield working..

my combobox working in my laptop but not in server.. im using CentOS 6.3 with php-xml installed.. what happen..?
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users