Yii Framework Forum: [SOLVED] dropdownlist pada form - Yii Framework Forum

Jump to content

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

[SOLVED] dropdownlist pada form Rate Topic: -----

#1 User is offline   DamnLuck 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 21
  • Joined: 13-September 11
  • Location:Depok

Posted 26 September 2011 - 12:16 PM

agan agan sekalian ane punya satu dropdownlist yang isinya dari sebuah tabel.
ane udah bikin functionnya datanya emang masuk dan ketika di submit benar isinya.
tapi ga ada tampilannya ya ..

tampilannya jadi gini
Posted Image

function di model nya
public function getNamaKerani()
    {
        $connection=Yii::app()->db;
        $sql="SELECT account_name FROM z_chart_master WHERE masterid >= '62' and masterid <= '91'";
        $krani=$connection->createCommand($sql)->query();
        $krani->bindColumn(1,$typeid);
        $krani->bindColumn(2,$cost_center_name);
      
        while($krani->read()!==false)
        {
            $nama[$typeid]=$cost_center_name;
          
          
        }
        return $nama;
    }


ini di formnya

<div class="row">
        <?php echo $form->labelEx($model,'cost_center_name'); ?>
        <?php echo $form->dropDownList($model,'cost_center_name',ChartMaster::getNamaKerani());?>
        <?php echo $form->error($model,'cost_center_name'); ?>
</div>

0

#2 User is offline   ibiz4 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 149
  • Joined: 26-November 10

Posted 26 September 2011 - 07:43 PM

Karena keluaran read() mungkin


public array|false read()
{return} array|false the current row, false if no more row available
WYSIWYG
(What Yii Serve is What You Get)
0

#3 User is offline   Mr D 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 217
  • Joined: 18-May 11

Posted 26 September 2011 - 11:54 PM


<div class="row">
		<?php echo $form->labelEx($model,'type'); ?>
		<?php echo $form->dropDownList($model,'type',CHtml::listData(BscType::model()->findAll('deleted IS NULL or deleted <> :deleted',array(':deleted'=>1)), 'id', 'name'),array('empty'=>'--Please Select One--')); ?>
		<?php echo $form->error($model,'type'); ?>
	</div>



saya biasanya bikinya gini..ga pake function2 lg...

semoga membantu
Boss: "We found a bug in your code!"
Programmer: "That's no bug, that's just an undocumented feature!"
0

#4 User is offline   loper_kesasar 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 104
  • Joined: 31-March 11

Posted 27 September 2011 - 12:16 AM

ane newbie nih di YII mau tanya juga,,
kalau di form ane
CHtml::listData(DataLksa::model()->findAll(),'kode_lksa','lksa_name'),

itu kan bakal nampilin semua LKSA kalau ane mau bkin yang muncul cuma yang namannya beda dan kodenya beda aja gimana ya?
0

#5 User is offline   DamnLuck 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 21
  • Joined: 13-September 11
  • Location:Depok

Posted 27 September 2011 - 12:29 AM

View PostMr D, on 26 September 2011 - 11:54 PM, said:


<div class="row">
		<?php echo $form->labelEx($model,'type'); ?>
		<?php echo $form->dropDownList($model,'type',CHtml::listData(BscType::model()->findAll('deleted IS NULL or deleted <> :deleted',array(':deleted'=>1)), 'id', 'name'),array('empty'=>'--Please Select One--')); ?>
		<?php echo $form->error($model,'type'); ?>
	</div>



saya biasanya bikinya gini..ga pake function2 lg...

semoga membantu



masalahnya data yang mau saya ambil, ada di tabel ang berbeda gan .. :(

gmn ya ?
0

#6 User is offline   Mr D 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 217
  • Joined: 18-May 11

Posted 27 September 2011 - 12:38 AM

y bikinin aja jadi model table ny...

CHtml::listData(BscType::model()->findAll('deleted IS NULL or deleted <> :deleted',array(':deleted'=>1))

BscType itu model..
Boss: "We found a bug in your code!"
Programmer: "That's no bug, that's just an undocumented feature!"
0

#7 User is offline   Mr D 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 217
  • Joined: 18-May 11

Posted 27 September 2011 - 01:18 AM

View Postloper_kesasar, on 27 September 2011 - 12:16 AM, said:

ane newbie nih di YII mau tanya juga,,
kalau di form ane
CHtml::listData(DataLksa::model()->findAll(),'kode_lksa','lksa_name'),

itu kan bakal nampilin semua LKSA kalau ane mau bkin yang muncul cuma yang namannya beda dan kodenya beda aja gimana ya?


maksudnya namanya beda gmn y??
Boss: "We found a bug in your code!"
Programmer: "That's no bug, that's just an undocumented feature!"
0

#8 User is offline   DamnLuck 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 21
  • Joined: 13-September 11
  • Location:Depok

Posted 27 September 2011 - 03:03 AM

View PostMr D, on 27 September 2011 - 12:38 AM, said:

y bikinin aja jadi model table ny...

CHtml::listData(BscType::model()->findAll('deleted IS NULL or deleted <> :deleted',array(':deleted'=>1))

BscType itu model..


terimakasih sarannya gan ;)

hasilnya jadi gini
Posted Image
yang muncul cuma satu value gan :( .
code nya :
CHtml::listData(ChartMaster::model()->findAll('typeid = 11',array('typeid'=>1)), 'typeid','account_name'),array('empty'=>'--Please Select One--'));




tapi hasilnya jadi gini
Posted Image
semua typeid nya muncul. :D
code nya :
CHtml::listData(ChartMaster::model()->findAll('typeid = 11',array('typeid'=>1)), 'account_name','typeid'),array('empty'=>'--Please Select One--'));

0

#9 User is offline   Mr D 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 217
  • Joined: 18-May 11

Posted 27 September 2011 - 03:11 AM

CHtml::listData(ChartMaster::model()->findAll('typeid = 11',array('typeid'=>1)), 'typeid','account_name'),array('empty'=>'--Please Select One--'));

kalau di atas itu dy ambil data yang typeid = 11..jadi cmn 1 munculnya...
kalau mau munculin semua dalam 1 table itu gini

CHtml::listData(ChartMaster::model()->findAll(), 'typeid','account_name'),array('empty'=>'--Please Select One--'));




Boss: "We found a bug in your code!"
Programmer: "That's no bug, that's just an undocumented feature!"
0

#10 User is offline   DamnLuck 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 21
  • Joined: 13-September 11
  • Location:Depok

Posted 27 September 2011 - 03:14 AM

View PostMr D, on 27 September 2011 - 03:11 AM, said:

CHtml::listData(ChartMaster::model()->findAll('typeid = 11',array('typeid'=>1)), 'typeid','account_name'),array('empty'=>'--Please Select One--'));

kalau di atas itu dy ambil data yang typeid = 11..jadi cmn 1 munculnya...
kalau mau munculin semua dalam 1 table itu gini

CHtml::listData(ChartMaster::model()->findAll(), 'typeid','account_name'),array('empty'=>'--Please Select One--'));



masalahnya gan, yang typeid nya 11 itu ada 30 account_name ..
0

#11 User is offline   Mr D 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 217
  • Joined: 18-May 11

Posted 27 September 2011 - 03:19 AM


CHtml::listData(ChartMaster::model()->findAll('typeid = :typeid',array(':typeid'=>11)), 'typeid','account_name'),array('empty'=>'--Please Select One--'));

coba d seperti ini...

Boss: "We found a bug in your code!"
Programmer: "That's no bug, that's just an undocumented feature!"
0

#12 User is offline   DamnLuck 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 21
  • Joined: 13-September 11
  • Location:Depok

Posted 27 September 2011 - 03:24 AM

View PostMr D, on 27 September 2011 - 03:11 AM, said:

CHtml::listData(ChartMaster::model()->findAll('typeid = 11',array('typeid'=>1)), 'typeid','account_name'),array('empty'=>'--Please Select One--'));

kalau di atas itu dy ambil data yang typeid = 11..jadi cmn 1 munculnya...
kalau mau munculin semua dalam 1 table itu gini
[code][code]
[code]CHtml::listData(ChartMaster::model()->findAll(), 'typeid','account_name'),array('empty'=>'--Please Select One--'));



[/code][/code][/code]
wah, makasih sarannya gan, ane baru sadar lihat comment agan yang diatas .

ane putusin bikin satu tabel lagi yang khusus nyimpen account_name yang typeid nya 11

dan sukses .. ;)

code nya jadi gini gan
CHtml::listData(CostCentre::model()->findAll(), 'id','cost_centre_name'),array('empty'=>'--Please Select One--'));

0

#13 User is offline   Mr D 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 217
  • Joined: 18-May 11

Posted 27 September 2011 - 03:29 AM

View PostDamnLuck, on 27 September 2011 - 03:24 AM, said:

[/code][/code][/code]
wah, makasih sarannya gan, ane baru sadar lihat comment agan yang diatas .

ane putusin bikin satu tabel lagi yang khusus nyimpen account_name yang typeid nya 11

dan sukses .. ;)

code nya jadi gini gan
CHtml::listData(CostCentre::model()->findAll(), 'id','cost_centre_name'),array('empty'=>'--Please Select One--'));



hooo...tp apa ga repot itu bikin table lg??hehehe

ga coba ini aja
CHtml::listData(ChartMaster::model()->findAll('typeid = :typeid',array(':typeid'=>11)), 'typeid','account_name'),array('empty'=>'--Please Select One--'));

Boss: "We found a bug in your code!"
Programmer: "That's no bug, that's just an undocumented feature!"
0

#14 User is offline   DamnLuck 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 21
  • Joined: 13-September 11
  • Location:Depok

Posted 27 September 2011 - 03:35 AM

View PostMr D, on 27 September 2011 - 03:29 AM, said:

hooo...tp apa ga repot itu bikin table lg??hehehe

ga coba ini aja
CHtml::listData(ChartMaster::model()->findAll('typeid = :typeid',array(':typeid'=>11)), 'typeid','account_name'),array('empty'=>'--Please Select One--'));




yang ini ane coba masih aja yang keluar cuma si KERANI RONI doang gan ..
yah, mau ga mau ane bikin tabel lagi, biar cepet gan ..
hehhe ..

tapi kalo ada saran yang lain ga apa-apa gan, biar nanti yang baca topic ini bisa pake, dan ga usah bikin tabel baru :P
0

#15 User is offline   ramdhan_055 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 05-February 12

Posted 09 February 2012 - 11:38 AM

wah untung ada tret ini... makasih.. ^^ problem yang sama.. solved
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