Hi All,
I just wanna create checkbox list, my problem here is along with each check box i just wanna show the other details (more than one) from the db query result
<checkbox1> {dbobj->field1}{dbobj->field2}{dbobj->field3} <checkbox2> <checkbox3>
I created the data by using listData(), but its allowing me to get only one field value.
Is there any way to solve this problem?
cyberpol
(Cyberpol 777)
May 13, 2009, 5:15pm
2
You shoul create a custom getCustomProperty in you model dbobj
For example:
public function getCustomProperty()
{
return $this->field1.' - '.$this->dbobj2;
}
then you use
<checkbox1> {dbobj->scustomProperty} <checkbox2> <checkbox3>
getCustomPropery becomes customProperty but you can use whatever you want.
I am sry, I didn’t get you…
cyberpol
(Cyberpol 777)
May 13, 2009, 6:58pm
4
Suposse that you have an model called Person
Person has two attributes, let's say name, lastname.
If Person is a child of ActiveRecord, then you can access these properties in the following way:
$person->name;
$person->lasname;
Right?
Well, but you can't use for example
<checkbox1> {$person->name}{$person->lastname} <checkbox2> <checkbox3>
Tod that you should create a neu method in the Person class
Let's say:
public function getFullname()
{
return $this->name.', '.$this->lasname;
}
then you can use simply
<checkbox1> {$person->fullname} <checkbox2> <checkbox3>
This is something like making a string of the result and assigning to a variable. But the answer I looking for is not this, sry.
I just wanna show the result of a findAll() , that means,
<checkbox> {first row in the result set} <checkbox2><checkbox3>
<checkbox> {second row in the result set} <checkbox2><checkbox3>
…
Is there anybody to help me out ?
qiang
(Qiang Xue)
May 15, 2009, 1:01am
7
For your problem, it is better to directly write PHP code to achieve it. There's no such support in Yii.