Yii Framework Forum: Dropdownlist - Yii Framework Forum

Jump to content

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

Dropdownlist menampilkan field sesuai jumlah yang dipilih pada dropdownlist Rate Topic: -----

#1 User is offline   santi maria 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 17-April 13

Posted 04 July 2013 - 05:38 AM

buat agan2 semuanya
saya minta bantuannya nih.
gimana sih caranya untuk menampilkan field sesuai jumlah yang dipilih pada driopdownlist
0

#2 User is offline   secharix 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 10-January 13
  • Location:Indonesia-Rest of the world

Posted 08 July 2013 - 02:08 AM


$limit  = [size=2]$_POST['limit'][/size]

$model = PostCategory::model();
    $record = $model->with(array(
      'posts'=>array(
         'order'=>'posts.createTime DESC',
      ))->findByPK($id,
                 array('limit'=>$limit,'together'=>true) // adding this works
    );




pakai limit aja gan, contoh limitnya di post dalam hal ini $_POST['limit']...yg bisa di request dari menunya




Toruh maruhur, dear marhasoman
0

#3 User is offline   Mr. Ravero 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 27
  • Joined: 30-April 13
  • Location:West Java

Posted 31 August 2014 - 11:33 PM

Gan Cara buat selected option di CHtml::dropdownlist gmana?

di Model

 public function getWordValue($value){
		if($value == 1){ return "Competency"; } else { return "Dev Recommendation"; }
	}


di view

array(
'name'=>'word_type2',
'header'=>'Word Type',
'value'=>'PCompetencyWords::model()->getWordValue($data->word_type)',
'filter'=>CHtml::dropDownList('PCompetencyWords[word_type2]', PCompetencyWords::model()->getWordValue($data->word_type),array('1'=>'Competency', '2'=>'Dev Recommendation'),array('empty'=>'Dev Recommendation')),
'type'=>'raw'
),


controller

public function actionAdmin()
	{
				$model=new PCompetencyWords('search');		
                $mCompetency = new PCompetency;
                
                $model->unsetAttributes();  // clear any default values
				if(isset($_GET['PCompetencyWords']))
				$model->attributes=$_GET['PCompetencyWords'];
                
                $selComp = $_GET['PCompetency']['comp_id'];
                $selType = $_GET['PCompetencyWords']['word_type'];
                $model->comp_id = $selComp;
                $model->word_type = $selType;
                                
                
                $mCompLabel = new PCompetencyJobtarget;
                $mCompLabel->compjt_id = $_POST['PCompetencyJobtarget']['compjt_id'];
                
                $mWordType = array(1=>'Competency',2=>'Recommendation');
                $model->word_type = $_POST['PCompetencyWords']['word_type'];
                
		$this->render('admin',array(
			'model'=>$model, 'mCompetency'=>$mCompetency, 'selComp'=>$selComp, 'selType'=>$selType, 'mCompLabel'=>$mCompLabel, 'mWordType'=>$mWordType
		));
	}


jadi tampilannya itu kayak seperti ini

<option selected="selected" value="2">Contoh</option>

Minta Bantuannya ya gan, thanks..
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