Re: Check boxes for a noob
Is this line 12? If yes, then check that you are providing a valid user id! The error message clearly states that line 12 is in error, and that the 'id' is not a known index in some array! Therefore, is the above line 12? The rest is up to you, enjoy, John On Aug 2, 1:46 pm, Michael Gaiser wrote: > So I am trying to get these check boxes to populate correctly and save to > the DB. (The Select window is too prone to messing things up). Any ideas why > the check boxes arnt bring checked properly? Also when I change it to just a > normal select list ('multiple'='true') I still get this: > > *Notice* (8): Undefined index: id [*APP\views\users\admin_edit.ctp*, line > *12*] > > I would be grateful for any help. > > ~Michael > [snip] > > The View: > Edit User Record (Admin Mode) > > > hidden('User.id'); ?> > > label('User.username'); ?> > error('User.username'); ?> > text('User.username', array('size' => '80' ) ); ?> > > label('User.Group', 'User Group (listed according to > access rights)' ); ?> > error('User.Group', 'You must select a user group'); > ?> [snip] > submit('Save Changes'); ?> > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Check boxes for a noob
groupId doesnt seem to work either. This is what the group array looks like. [Group] => Array ( [0] => Array ( [id] => 2 [name] => Standard User [created] => 2009-07-30 21:55:03 [modified] => 2009-07-30 21:55:03 ) ) How do I pass that to the 'selected'=> option so I can tell which checkboxes are selected? Do I need to tweak the array before I set it to the view? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Check boxes for a noob
Try inflecting your groupid: input('User.Group', array('type'=>'select', 'value'=>$this->data['User']['groupId'], 'options'=>$groups, 'multiple'=>'checkbox')); ?> Controllers use the underscore, but views use camelCase, so that might be what's choking it. On Aug 2, 11:46 am, Michael Gaiser wrote: > So I am trying to get these check boxes to populate correctly and save to > the DB. (The Select window is too prone to messing things up). Any ideas why > the check boxes arnt bring checked properly? Also when I change it to just a > normal select list ('multiple'='true') I still get this: > > *Notice* (8): Undefined index: id [*APP\views\users\admin_edit.ctp*, line > *12*] > > I would be grateful for any help. > > ~Michael > > The Controller: > > function admin_edit($id = null) { > $groups = $this->User->Group->find("list"); > $this->set('groups', $groups); > if (empty($this->data)) { > $this->User->id = $id; > $this->data = $this->User->read(); > $this->data['User']['old_email'] = $this->data['User']['email']; > } else { > if($this->data['User']['old_email'] != > $this->data['User']['email']) { > $this->data['User']['confirm_code'] = String::uuid(); > $this->data['User']['confirmed'] = 0; > } > if($this->User->save($this->data)) { > if($this->data['User']['old_email'] != > $this->data['User']['email']) { > if($this->__sendEmail()) { > $this->Session->setFlash('Email has been sent'); > } else { > $this->Session->setFlash('Could not send Email'); > } > } > $this->flash('Your changes have been > saved.','/admin/users/view/'.$this->data['User']['id'] ); > } > } > debug($groups); > debug($this->data); > } > > The View: > Edit User Record (Admin Mode) > > > hidden('User.id'); ?> > > label('User.username'); ?> > error('User.username'); ?> > text('User.username', array('size' => '80' ) ); ?> > > label('User.Group', 'User Group (listed according to > access rights)' ); ?> > error('User.Group', 'You must select a user group'); > ?> > input('User.Group', array('type'=>'select', > 'value'=>$this->data['User']['group_id'], 'options'=>$groups, > 'multiple'=>'checkbox')); ?> > > label('User.name', 'User Full Name'); ?> > text('User.name', array('size' => '80')); ?> > error('User.name'); ?> > > hidden('User.old_email'); ?> > label('User.email', 'User E-mail'); ?> > text('User.email', array('size' => '80')); ?> > error('User.email'); ?> > > label('User.active', 'Active'); ?> > select('User.active', array('0'=>'No', '1'=>'Yes')); > ?> > error('User.active'); ?> > > label('User.confirmed', 'Confirmed'); ?> > select('User.confirmed', array('0'=> 'No', > '1'=>'Yes')); ?> > error('User.confirmed'); ?> > > hidden('User.passwd'); ?> > > error('User.new_passwd'); ?> > > submit('Save Changes'); ?> > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Check boxes for a noob
So I am trying to get these check boxes to populate correctly and save to the DB. (The Select window is too prone to messing things up). Any ideas why the check boxes arnt bring checked properly? Also when I change it to just a normal select list ('multiple'='true') I still get this: *Notice* (8): Undefined index: id [*APP\views\users\admin_edit.ctp*, line *12*] I would be grateful for any help. ~Michael The Controller: function admin_edit($id = null) { $groups = $this->User->Group->find("list"); $this->set('groups', $groups); if (empty($this->data)) { $this->User->id = $id; $this->data = $this->User->read(); $this->data['User']['old_email'] = $this->data['User']['email']; } else { if($this->data['User']['old_email'] != $this->data['User']['email']) { $this->data['User']['confirm_code'] = String::uuid(); $this->data['User']['confirmed'] = 0; } if($this->User->save($this->data)) { if($this->data['User']['old_email'] != $this->data['User']['email']) { if($this->__sendEmail()) { $this->Session->setFlash('Email has been sent'); } else { $this->Session->setFlash('Could not send Email'); } } $this->flash('Your changes have been saved.','/admin/users/view/'.$this->data['User']['id'] ); } } debug($groups); debug($this->data); } The View: Edit User Record (Admin Mode) hidden('User.id'); ?> label('User.username'); ?> error('User.username'); ?> text('User.username', array('size' => '80' ) ); ?> label('User.Group', 'User Group (listed according to access rights)' ); ?> error('User.Group', 'You must select a user group'); ?> input('User.Group', array('type'=>'select', 'value'=>$this->data['User']['group_id'], 'options'=>$groups, 'multiple'=>'checkbox')); ?> label('User.name', 'User Full Name'); ?> text('User.name', array('size' => '80')); ?> error('User.name'); ?> hidden('User.old_email'); ?> label('User.email', 'User E-mail'); ?> text('User.email', array('size' => '80')); ?> error('User.email'); ?> label('User.active', 'Active'); ?> select('User.active', array('0'=>'No', '1'=>'Yes')); ?> error('User.active'); ?> label('User.confirmed', 'Confirmed'); ?> select('User.confirmed', array('0'=> 'No', '1'=>'Yes')); ?> error('User.confirmed'); ?> hidden('User.passwd'); ?> error('User.new_passwd'); ?> submit('Save Changes'); ?> --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---