Easy as cake my friend.

 

Just use this code, and build the list for your checkboxes...

 

            $selected_users=array();

 

            if (empty($this->data)) {

                  $this->data = $this->Site->read(null, $id);

/*

                  here you would replace the data=read with something like

                  $ali_list =
$this->Aliquot->find('all',array('conditions'=>.)). and get whatever you
need to make a list of.

 

                  As long as your models are set up correctly you should
have all the related data that you need to build your names

*/

                  //    below modify the references to $this->data. and
replace them with the array structure of $ali_list

                  foreach($this->data['User'] as $user){

                        if(is_array($user)){

//                            extract($user,EXTR_PREFIX_ALL,'user');

                              extract($ali_list,EXTR_PREFIX_ALL,'ali');

                              if($user_id !=
$this->data['Site']['admin_id']){

                                    $selected_users[$ali_id]=$ali_username;

                              }

                        }

                  }

            }

 

Then use this code to display it.

 

<?php

echo $form->input(

      'Category',

      array(

            'type'=>'select',

            'multiple'=>'checkbox',

            'options'=>$categories,

            'label'=>false

            )

      );

?>

 

Don't worry about the 'label' = false.

 

What you are doing is making a multi select box with no label and displaying
the individual options as checkboxes.  Internally, cake will convert this to
checkboxes and labels.

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf
Of Tony Thomas
Sent: Thursday, January 15, 2009 5:09 PM
To: CakePHP
Subject: Re: Label information for Multiple Checkboxes

 

 

On Jan 15, 1:03 pm, "David Coleman" <[email protected]>

wrote:

> Do you need checkboxes from multiple tables?  

 

No. The checkboxes in this case only pertain to my aliquots table so

that users can assign them to a box, which is in turn assigned to a

freezer. But in order to identify where the aliquots go, there are a

few fields from my specimens table (blood comes in as a specimen and

is then divided into aliquots) that I'd like to display in the label.

 

If so you need to use the

> trick I posted earlier today to make the hidden elements not be
duplicated.

> Overload your form.php in your app/views/helpers folder.

> 

> What you are doing is similar to a recent application that I wrote, in
which

> I developed this extention to the form->input method to accomplish just
this

> effect.

> 

> See the message "re: Ticket #5577 (new Enhancement)"  If this is what you

> need.

> 

> -----Original Message-----

> From: [email protected] [mailto:[email protected]] On
Behalf

> 

> Of Tony Thomas

> Sent: Thursday, January 15, 2009 4:52 PM

> To: CakePHP

> Subject: Re: Label information for Multiple Checkboxes

> 

> The complicating factor here is that Aliquot belongs to Specimen in my

> model and I want to display some information from both tables:

> Specimen.type, Specimen.draw_date, Aliquot.additive & etc. It looks

> more and more like I'm going to have to put that information in an

> array and loop through it, building each checkbox one at a time

> instead of my example below. Or am I missing something?

> 

> On Jan 15, 11:01 am, grigri <[email protected]> wrote:

> > You need to set the $displayField property inside your `Aliquot` model

> > to whatever field you want for the label.

> 

> > On Jan 15, 4:47 pm, Tony Thomas <[email protected]> wrote:

> 

> > > I'm building a list of checkboxes like so:

> 

> > > echo $form->input('Aliquot.id', array( 'label' => FALSE,

> > >


>         'type' => 'select',

> > >


>         'multiple' => 'checkbox',

> > >


>         'options' => $aliquots));

> > > echo $form->input('box_id', array('options' => $boxes));

> 

> > > $aliquots above is built from $this->Aliquot->find('list', $options);

> > > which finds all the ids of the pertinent records. The problem I have

> > > this this only generates a list of ids. Is there good way to load an

> > > array for 'label' so that I can display more than just the list of
ids?


 


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to