Yii Framework Forum: Bagaimana Mambuat Dropdownlist Dengan 2 Field - Yii Framework Forum

Jump to content

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

Bagaimana Mambuat Dropdownlist Dengan 2 Field Rate Topic: -----

#1 User is offline   masdib.banget 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 39
  • Joined: 02-July 13

Posted 05 September 2013 - 10:33 PM

Permisi gan,
bagaimana ya cara membuat dropdownlist dengan 2 field yg ditampilkan?
seperti : N,Samarinda;H,Semarang;B,Jakarta ?

skrg saya sudah bisa membuat dropdownlist tp yg ditampilkan cuma nama kotanya saja.

<?php 
echo $form->dropDownListRow($model,'cabang',CHtml::listData(Cabang::model()->findAll(array('order' => 'id ASC')), 
           'id', 'nama'),array('class'=>'span3', 'hint'=>'<i>Setelah disimpan, cabang/lokasi tidak dapat diganti.</i>', 'prompt'=>'Pilih Cabang ...'));
?>


bagaimana ya? menampilkan kode dan nama kota ya master???
0

#2 User is offline   ahmad taqwa 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 02-July 13

Posted 24 September 2013 - 10:59 PM

Semoga bisa membantu....

example

View

echo Chtml::dropDownList('list', $transaksi->kode_transaksi, $this->getHistoryAlamat(), array('empty' => 'pilih'));

Controller

public function getHistoryAlamat() {
$data = Transaksi::model()->findAll(array(
'condition' => 't.transaksi_kd_user = ' . Yii::app()->session['id_user'] . ' AND t.in_out="1"',
'select' => 'DISTINCT tujuan_nama, tujuan_kecamatan,tujuan_alamat, tujuan_kd_post, nama_kabupaten',
'join'=>'LEFT JOIN kabupaten as rKabupaten ON rKabupaten.kode_kabupaten = t.tujuan_kode_kabupaten',
));
$result = array();
foreach ($data AS $val) {
$result[$val->tujuan_nama] = array($this->getKdTransaksi($val->tujuan_nama, $val->tujuan_kecamatan) => $val->tujuan_alamat . ", " . $val->tujuan_kecamatan . ", " . $val->nama_kabupaten . ", " . $val->tujuan_kd_post );
}
return $result;
}
0

#3 User is offline   masdib.banget 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 39
  • Joined: 02-July 13

Posted 27 September 2013 - 04:36 AM

Rumit juga ya... mksh ya gan,,,,

dicoba dlu,

View Postahmad taqwa, on 24 September 2013 - 10:59 PM, said:

Semoga bisa membantu....

example

View

echo Chtml::dropDownList('list', $transaksi->kode_transaksi, $this->getHistoryAlamat(), array('empty' => 'pilih'));

Controller

public function getHistoryAlamat() {
$data = Transaksi::model()->findAll(array(
'condition' => 't.transaksi_kd_user = ' . Yii::app()->session['id_user'] . ' AND t.in_out="1"',
'select' => 'DISTINCT tujuan_nama, tujuan_kecamatan,tujuan_alamat, tujuan_kd_post, nama_kabupaten',
'join'=>'LEFT JOIN kabupaten as rKabupaten ON rKabupaten.kode_kabupaten = t.tujuan_kode_kabupaten',
));
$result = array();
foreach ($data AS $val) {
$result[$val->tujuan_nama] = array($this->getKdTransaksi($val->tujuan_nama, $val->tujuan_kecamatan) => $val->tujuan_alamat . ", " . $val->tujuan_kecamatan . ", " . $val->nama_kabupaten . ", " . $val->tujuan_kd_post );
}
return $result;
}

0

#4 User is offline   masdib.banget 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 39
  • Joined: 02-July 13

Posted 27 September 2013 - 04:39 AM

Baiknya getHistoryAlamat saya taruh di controller apa model gan Ahmad???
0

#5 User is offline   masdib.banget 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 39
  • Joined: 02-July 13

Posted 27 September 2013 - 09:37 PM

akhirnya bisa ... simple..
http://www.yiiframew...et-set-methods/
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