Thank you again. Right now I am not in the computer to modify my code, 
I am trying to install apache and mysql and php5 in my computer, so I 
can test it at home. I will go to the link you provide and try the 
code. Thank you!
Best Regards
Lynda

On Jan 29, 2:53 pm, "Mikee Freedom" <[EMAIL PROTECTED]> wrote:
> hey again Lynda,
>
> you'll have to excuse me, i'm a bit slow today due to a heavy long weekend.
>
> you don't need to define your own generateMenuList function as one has
> already been provided for you :
>
> http://manual.cakephp.org/chapter/models
> [search the page for 
> generateList]http://api.cakephp.org/class_model.html#e8844b859626edc554946480046e395f
>
> It is a function provided to you by the lovely developers at cake as a
> method of your model (and all models). It is ok for you to not include
> an id and name field in your table, just look at the instructions in
> the chapter and API which describe how to get around this.
>
> you should be able to replace your line :
>
> $this->set('Menu', $this->Setting->generateMenuList());
>
> with
>
> $this->set('Menu', $this->Setting->generateList(null,null, null,
> "Setting.setting","Setting.value"));
>
> Have a read of the manual and the API and see how you go.
>
> HTH,
> mikee
>
> On 30/01/07, lynda <[EMAIL PROTECTED]> wrote:
>
>
>
> > Thank you for reply. If you can look my code, I will be greatly
> > appreciated.
> > I did use goole to search how to generate a list. However, my
> > generateMenuList just return an empty list. The menu button doesn't
> > show any value, It is supposed to have 1, 2, 3, 4. By the way, my
> > table only has two fields: setting and value,, no id field.
> > Here is in my settings_controllers.php
> > //I put generateMenuList() in settings_controllers.php
>
> >         function generateMenuList()
> >         {
> >         $data = $this->Setting->findAll();
> >         $return = array();
> >         foreach ($data as $menu)
> >         {
> >                 $return[$menu['Setting']['value'] ]=$menu['Setting']
> > ['value'];
> >                  }
> >                  print_r($return);
> >                  return $return;
>
> >         }
> >         function edit($setting){
>
> >                 $data = $this->Setting->findAll(); //select all
> >                 $this ->set('settings_values',$data);//set fo finding values
> >                 $this->set('Menu', $this->Setting->generateMenuList());
>
> >                 if (empty($this->data['Setting'])){
> >                         $this->Setting->setting = $setting;
> >                         $this->data = $this->Setting->read();
> >                         $this->set('setting', 
> > $this->data['Setting']['setting']);
> >                 } else {
> >                         if($this->Setting->save($this->data['Setting'])){
> >                         $this->flash('Your setting has been 
> > updated.','/settings/');
> >                         }
> >                 }
> >         }
>
> > here is my edit.thml
> > <h1>Edit Setting</h1>
> > <form action="<?php echo $html->url('/settings/edit/'.$setting)?>"
> > method="post">
> > <?php
>
> > ?>
> > <pre>
> > <?php print_r($settings_values);
> > print_r($Menu);
> > ?>
> > pre>
>
> >    <p>
> >        Section:
> >        <?php echo $html->textarea('Setting/setting', Array("disabled"
> > => "disabled"));?>
>
> >    </p>
> >    <p>
>
> >        Position:
> >             <?php echo $html->selectTag('Setting/setting',
> >                                                                 $Menu,
> >                                                                 null,
> >                                                                 
> > array('multiple' => 'multiple', 'size' => sizeof($Menu)
> > +1));
> >         ?>
>
> >    <p>
> >        <?php echo $html->submit('Save'); ?>
> >    </p>
> > </form>


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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