Yii Framework Forum: Value Dropdownlist Kosong ? - Yii Framework Forum

Jump to content

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

Value Dropdownlist Kosong ? Rate Topic: -----

#1 User is offline   ngadat 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 28-September 13

Posted 30 September 2013 - 02:44 AM

dropDownList nya gak ber-value. knp sy katakan demikian karena pas sy submit itu formya eh malah muncul pesan klo field username-nya gak boleh kosong. artinya valuenya gak ada.
dropDownListnya sih jalan, ada pilihan yg tampil...

mohon penerangannya :)

ini dia source
$models = user::model()->findAll(array('order' => 'username'));
$listUser = CHTML::listData($models,'id','username');
echo CHTML::dropDownList('user_id',$id,$listUser,array('empty'=>'---- Pilih User ----'));

0

#2 User is offline   rei 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 323
  • Joined: 10-November 10

Posted 01 October 2013 - 07:38 AM

Atribut user_id udah dimasukkan ke rulesnya (di model), bro?

public function rules()
{
    return array(
       array('user_id', 'required'), // atau 
       array('user_id', 'safe'),  // (tergantung kebutuhan)
    );
}

Fipick - Find and pick recommendations
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