Yii Framework Forum: Drop Down List Always Inserting 1 In Db - Yii Framework Forum

Jump to content

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

Drop Down List Always Inserting 1 In Db using select drop down list the value is always taking 1 Rate Topic: -----

#1 User is offline   darsa 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 28-January 13

Posted 11 May 2013 - 01:50 AM

Here department is my table it contains only two fields id and department. My model name is also department.

This is my form

<?php echo $form->labelEx($model, 'department'); ?>
<select name="department">
<option value="select">select</option>
<?php for($i=1;$i<30;$i++) {?>

<option value="<?php echo $i; ?>"><?php echo $i; ?></option>
<?Php } ?>
</select>

While I clicking create button the value is inserted in the database is always one if I select any number the value is inserted is 1 can you help me please .
Thanks in advance .
0

#2 User is offline   Tsunami 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 150
  • Joined: 16-February 12

Posted 11 May 2013 - 04:06 AM

<?php $data = array_combine(range(1, 29), range(1, 29)); ?>
<?php echo $form->dropDownList($model, 'department', $data, array('empty' => 'select')); ?>

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