Problem With Dropdown List

I am getting some rather strange results when using active form dropdown

I have a table for user with a column for pagesize.

I have a edit view _form with the model data for pagesize

Yii::app()->params[‘pageSizeOptions’] is a constant defined in config/main.php as ‘pageSizeOptions’=>array(10=>10,20=>20,50=>50,100=>100,500=>500),




<div class="row">

            <?php echo $form->labelEx($model,'pagesize');   ?>        

   	    <?php echo $form->dropDownList($model,'pagesize', Yii::app()->params['pageSizeOptions']); ?>

            <?php echo $form->error($model,'pagesize'); ?>

        </div>



The field is rendered in a nice gray with up/down arrows. I am using the standard css files.

The issue I have is that when the user selects a value in the dropdown, the field turns from a nice gray to a green color

and gets ugly, each time you change it, it morphs a bit. It looks like a regular input text field except it is green. Or it

looks like a square dropdown with a bevel…it’s just ugly!

This seems to happen on dropDownList fields that do not use a dynamic list such as CHtml::listData() to create the array.

Any ideas ?

Thanks in advance for any assistance!

Dear Friend

kindly check whether following modification helps in our case.




<div class="row">

            <?php echo $form->labelEx($model,'pagesize');   ?>        

            <?php echo $form->dropDownList($model,'pagesize', Yii::app()->params['pageSizeOptions'],array("id"=>"someValue")); ?>

            <?php echo $form->error($model,'pagesize'); ?>

        </div>



The default value set by YII id YourModel_pagesize. Try to override that.

Thank you Seenivasan !

Unfortunately, a default value did not help the quirky behaviour.

I am running Firefox for a browser, not sure it does it on all other browsers.

I am confident that it seems to be related to having a static data set. If I use a model and pull data it works great!

Do you have client/ajax validation set to ‘true’? From your description, it seems that when you’re selecting the dropdown value, some sort of validation is happening which in turn is giving the “green” color (which means that the validation passed for that particular field).

I am really sorry about that.

I tested default login form in yii. It is ideal because it is ajax enabled.

I made a dropdown list with admin and demo.

I experienced the same problem you are having.

This solved th issue.




<div class="row">

		<?php echo $form->labelEx($model,'username'); ?>

		<?php echo $form->dropDownList($model,'username',array('admin'=>"admin",'demo'=>"demo"),array("id"=>"name")); ?>

		<?php echo $form->error($model,'username'); ?>

	</div>



One more thing is that because it is a dropdownlist and there is likely chance for erroneous inputs

avoid validation rules for pagesize.

Regards

Thanks guys !

I will try the column identifiers and see if that helps.

I don’t have ajax validation on in the form.

That worked ! Thank you!

Not sure why it did not work last night…probably sleep deprivation.