Re: Problem in using elements
Thanks John!! I wrote a function to load the data into the form and my edit form is working now :jumping: Thank you very much :-) -- View this message in context: http://old.nabble.com/Problem-in-using-elements-tp28380990p28386698.html Sent from the CakePHP mailing list archive at Nabble.com. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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: Problem in using elements
That is what I wrote you! You want to show the edit form (from the edit element) in another view, that is use it within another action (controller/foo), am I correct? So in your foo action, you have to make sure that the $this->data array is filled with the same information as in the edit action - which means that you have to fill is with the user data, just as you did in the edit action. [code] function foo() { // some other code $this->data = $this->User->read(null, $id); } [/code] This is because the form helper in your edit element reads the data to use from the $this->data array! Hope the above helps you on the way, John On Apr 27, 10:36 pm, sherzo wrote: > Hi John > Thanks for your quick reply! > here is my edit method : > > function edit($id = null) { > if (!$id && empty($this->data)) { > $this->Session->setFlash(__('Invalid User', true)); > $this->redirect(array('action'=>'login')); > } > if (!empty($this->data)) { > if ($this->User->save($this->data)) { > $this->Session->setFlash(__('The User has > been saved', true)); > $this->redirect(array('action'=>'index')); > } else { > $this->Session->setFlash(__('The User could > not be saved. Please, try > again.', true)); > } > } > if (empty($this->data)) { > $this->data = $this->User->read(null, $id); > } > $coupons = $this->User->Coupon->find('list'); > $this->set(compact('coupons')); > } > > Actually it's working from edit view but not from edit element!!! I'm new in > cakephp!! is there anything special with elements? aren't they working just > like views? > > Thanks > Sherry [snip] Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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: Problem in using elements
Hi John Thanks for your quick reply! here is my edit method : function edit($id = null) { if (!$id && empty($this->data)) { $this->Session->setFlash(__('Invalid User', true)); $this->redirect(array('action'=>'login')); } if (!empty($this->data)) { if ($this->User->save($this->data)) { $this->Session->setFlash(__('The User has been saved', true)); $this->redirect(array('action'=>'index')); } else { $this->Session->setFlash(__('The User could not be saved. Please, try again.', true)); } } if (empty($this->data)) { $this->data = $this->User->read(null, $id); } $coupons = $this->User->Coupon->find('list'); $this->set(compact('coupons')); } Actually it's working from edit view but not from edit element!!! I'm new in cakephp!! is there anything special with elements? aren't they working just like views? Thanks Sherry John Andersen-6 wrote: > > In the controller action for the view in which you are using the edit > element, make sure that you fill out the $this->data array with the > data that the edit element need! > As you are using the form helper in the edit element, then the form > helper takes the data from $this->data. > Enjoy, >John > > On Apr 27, 10:23 pm, sherzo wrote: >> Hi all!!! >> I have a user edit page, which works perfectly. Somehow I need to make an >> element of the the edit form and load it in another page as well. but >> when I >> load the edit element its an empty page!!! How can I load the date to the >> form while its an element? >> Any idea?? >> here is my edit.ctp >> >> create('User', array('action' => 'edit','type' => >> 'post','class'=>'center', 'id' => 'kaydet', 'name' => 'kaydet' ));?> >> Ad, Soyad image("firsat-bullet.gif", >> array("align" >> => "absmiddle", "alt" =>"" )); ?> >> > echo $form->input('id',array('type' => 'hidden')); >> echo $form->input('username', array('type' => 'hidden')); >> echo $form->text('first_name',array('class' => 'formInput')); >> echo $form->text('last_name',array('class' => 'formInput')); >> ?> >> Kartýnýzýn arkasýndaki son 3 rakam. >> >> E-Postaimage("firsat-bullet.gif", array("align" >> => >> "absmiddle", "alt" =>"" )); ?> >> >> >> text('email',array('class' => 'formInput')); >> ?> >> >> >> Cep Telefonuimage("firsat-bullet.gif", >> array("align" >> => "absmiddle", "alt" =>"" )); ?> >> >> text('telephone',array('class' => 'formInput')); >> ?> >> >> >> >> submit('degisikleri-kaydet-button.gif', >> array('class'=>'submit'));?> >> >> >> end(); ?> >> -- >> View this message in >> context:http://old.nabble.com/Problem-in-using-elements-tp28380990p28380990.html >> Sent from the CakePHP mailing list archive at Nabble.com. >> >> Check out the new CakePHP Questions sitehttp://cakeqs.organd help others >> with their CakePHP related questions. >> >> 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 >> athttp://groups.google.com/group/cake-php?hl=en > > Check out the new CakePHP Questions site http://cakeqs.org and help others > with their CakePHP related questions. > > 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 > > -- View this message in context: http://old.nabble.com/Problem-in-using-elements-tp28380990p28381113.html Sent from the CakePHP mailing list archive at Nabble.com. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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: Problem in using elements
In the controller action for the view in which you are using the edit element, make sure that you fill out the $this->data array with the data that the edit element need! As you are using the form helper in the edit element, then the form helper takes the data from $this->data. Enjoy, John On Apr 27, 10:23 pm, sherzo wrote: > Hi all!!! > I have a user edit page, which works perfectly. Somehow I need to make an > element of the the edit form and load it in another page as well. but when I > load the edit element its an empty page!!! How can I load the date to the > form while its an element? > Any idea?? > here is my edit.ctp > > create('User', array('action' => 'edit','type' => > 'post','class'=>'center', 'id' => 'kaydet', 'name' => 'kaydet' ));?> > Ad, Soyad image("firsat-bullet.gif", array("align" > => "absmiddle", "alt" =>"" )); ?> > echo $form->input('id',array('type' => 'hidden')); > echo $form->input('username', array('type' => 'hidden')); > echo $form->text('first_name',array('class' => 'formInput')); > echo $form->text('last_name',array('class' => 'formInput')); > ?> > Kartýnýzýn arkasýndaki son 3 rakam. > > E-Postaimage("firsat-bullet.gif", array("align" => > "absmiddle", "alt" =>"" )); ?> > > > text('email',array('class' => 'formInput')); > ?> > > > Cep Telefonuimage("firsat-bullet.gif", array("align" > => "absmiddle", "alt" =>"" )); ?> > > text('telephone',array('class' => 'formInput')); > ?> > > > > submit('degisikleri-kaydet-button.gif', > array('class'=>'submit'));?> > > > end(); ?> > -- > View this message in > context:http://old.nabble.com/Problem-in-using-elements-tp28380990p28380990.html > Sent from the CakePHP mailing list archive at Nabble.com. > > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others with > their CakePHP related questions. > > 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 > athttp://groups.google.com/group/cake-php?hl=en Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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
Problem in using elements
Hi all!!! I have a user edit page, which works perfectly. Somehow I need to make an element of the the edit form and load it in another page as well. but when I load the edit element its an empty page!!! How can I load the date to the form while its an element? Any idea?? here is my edit.ctp create('User', array('action' => 'edit','type' => 'post','class'=>'center', 'id' => 'kaydet', 'name' => 'kaydet' ));?> Ad, Soyad image("firsat-bullet.gif", array("align" => "absmiddle", "alt" =>"" )); ?> input('id',array('type' => 'hidden')); echo $form->input('username', array('type' => 'hidden')); echo $form->text('first_name',array('class' => 'formInput')); echo $form->text('last_name',array('class' => 'formInput')); ?> Kartınızın arkasındaki son 3 rakam. E-Postaimage("firsat-bullet.gif", array("align" => "absmiddle", "alt" =>"" )); ?> text('email',array('class' => 'formInput')); ?> Cep Telefonuimage("firsat-bullet.gif", array("align" => "absmiddle", "alt" =>"" )); ?> text('telephone',array('class' => 'formInput')); ?> submit('degisikleri-kaydet-button.gif', array('class'=>'submit'));?> end(); ?> -- View this message in context: http://old.nabble.com/Problem-in-using-elements-tp28380990p28380990.html Sent from the CakePHP mailing list archive at Nabble.com. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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