activeTextField()

hi all,

i am in a need of populating a column values from database into Text boxes.

I am able to display the data in activechecboxlist, as




<td><?php echo $form->labelEx($model,'charge_amount'); ?></tD>

<td><?php  echo CHtml::activeCheckBoxList($model, 'charge_amount',    CHtml::listData(ChargesDemandMaster::model()->findAll(), 'Demand_amount', 'Demand_amount'), array('empty' => '--Select a category--', 'multiple'=>'multiple')); ?></td>



I have a column values as AMOUNT(100,2322,…)

Here the amount will be displayed dynamically from the amount column in a certain table as a check-box-list. i want to load the same data in text boxes

were the customer can edit if he wants.

If i write this just a single textbox is getting displayed.




    	<td><?php  echo CHtml::activeTextField($model, 'charge_amount', CHtml::listData(ChargesDemandMaster::model()->findAll(), 'Demand_amount', 'Demand_amount'), array('empty' => '--Select a category--', 'multiple'=>'multiple')); ?></td>




thanks $ regards,

rama.

First of all, CHtml::activeTextField() takes only 3 parameters ($model, $attribute and $htmlOptions). Unlike CHtml::activeCheckBoxList, it doesn’t take a data array parameter. Look it up in the reference. http://www.yiiframework.com/doc/api/1.1/CHtml#activeTextField-detail

I guess you want something like a “comboBox” in Windows desktop app, or, in other word, an “editable drop down list”. Am I right? But it’s not supported either in HTML or in Yii framework AFAIK.

So you have to consider other approaches.

What I can think of are …

  1. textField + doropDownList + javaScript to populate the selected value of dropDownList to textField

  2. making use of CJuiAutocomplete

  3. search some library to implement an "editable dropDownList"


[EDIT]

Ah, you want 2 or more textFields to be displayed. Right?

Then my post is kind of out of focus. Sorry!!

But CHtml::activeTextField is just for a single text box.

Thanks for the reply.

I tried this in the from.php. I am able to get textboxes filled with data. But when is say save the textbox values are not getting saved.

the code i wrote is




 <td>	<?php

     $demandamount= Yii::app()->db->createCommand(array(

     			 'select' => 'Demand_amount',

 				   'from' => 'tbl_charges_demand_master',

				               ))->queryColumn();

	    for($i=0;$i<count($demandamount);$i++)

	    	echo CHtml::activeTextField($model,'collected_amount',array('size'=>5,'maxlength'=>5, 'value' => $demandamount[$i])); ?>




I’m sorry, but I don’t understand what you want to do.

Where do you want to save the "demandamount" data? To "ChangeDemandMaster" table, or to the current table of the model?

And what are the table schema for them?

And what is the relation between them?