select list not show in my form

Permalink 2 users found helpful
Hi

single pages.php
$form = Loader::helper('form');
<td><label for="eRole"><?php echo t('Role')?>:</label></td>
<td><?php echo $form->select('eRole', $role); ?></td>



controller.php
Loader::model('employeeinfo');
      $rArr = employeeinfo::get();
      $this->set('role',$rArr);


the output i attached the file pfa...

how to solve this?

1 Attachment

 
ronyDdeveloper replied on at Permalink Reply
ronyDdeveloper
Check the array that you generated and the general array that select method accepts.

Rony
shankumars replied on at Permalink Reply 1 Attachment
Hi rony
If i create a array manually is working properly
my coding

$arr = Array ('kumar', 'Kamal', 'Chandru');
$this->set('Arole',$arr);

<td><?php echo $form->select('eRole', $Arole); ?></td>

and also i attached o/p PFA

Now how to solve my previous question

my updated this line
I try to convert the dataset to array



Loader::model('employeeinfo');
      $rArr = employeeinfo::get();
$rol = array();
   foreach($rArr as $w){   
   echo "<pre>".($w['role_name'])."</pre>";//o/p: Admin Jr. Enginner Sr. Enginner
   $rol .= $w['role_name'];
   }
   echo "<pre>";
   print_r($rol);//o/p: ArrayAdminJr. EnginnerSr. Enginner
   echo "</pre>"; 
   $this->set('abc',$rol);//


<td><?php echo $form->select('eRole', $abc); ?></td>

Warning: Invalid argument supplied for foreach() in /home/kumar/public_html/amsConcrete/concrete/core/helpers/form.php on line 347



Thanks
ronyDdeveloper replied on at Permalink Reply
ronyDdeveloper
I think the array should be in key=>value combination.

Rony
shankumars replied on at Permalink Reply
I dnot know about the key=>value, how to solve this?
shankumars replied on at Permalink Best Answer Reply
I got the result.

the helpers/form donot accept the dataset value, so the dataset value to convert the array and pass the parameter of select('eRole', $role). its work properly.

following this code
Single Page.php
<td><label for="eRole"><?php echo t('Role')?>:</label></td> 
       <td><?php echo $form->select('eRole', $role);?> </td>


Controllers.php
Loader::model('employeeinfo');
      $role = employeeinfo::get();
      $rolearr[] = "------------";      
      foreach($role as $temp){         
         $rolearr[] = $temp['role_name'];
      }      
      $this->set('role', $rolearr);


thanks rony after your comment i have workout again and again. I get the idea.


thanks
Kumar