Yii Framework Forum: checkbox checking - Yii Framework Forum

Jump to content

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

checkbox checking Rate Topic: -----

#1 User is offline   Dazza 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 9
  • Joined: 16-November 11
  • Location:NZ

Posted 20 November 2011 - 08:24 PM

I have a checkbox which is checking itself when it gets passed an object where the PK is 1,

Assume $posts is all the equipment in the table :
$posts= Equipment::model()->findAll();

<div class="checkboxes"><?php foreach ($posts as $equipment) {
                                ?><div><?php
                                
                                    echo $form->checkBox($equipment, "[$equipment->equipment_id]equipment_id", array('autocomplete' => 'off'));
                                    echo $form->labelEx($equipment,"[$equipment->equipment_id]".$equipment->equipment_name ); 
                                    echo $form->error($equipment, 'equipment_name'); 
                                ?></div><?php
                            } ?>
                        </div>


In my table I have
equipment_id, equipment_name
1 Hard Hat
2 Hat/ Hair Enclosure
3 Safety Glasses

When i render a blank form, it checks "hard hat" by default. I tried autocomplete off, but if i delete "Hard Hat" from the database then it is fine. But if the ID is 1, then it seems to be checking my tick box.
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