Your form is submitting to the add action.
On Fri, Jun 7, 2013 at 12:45 PM, Karl Smith <barnunboi@hotmail.com> wrote:
I'm having a problem with my edit action and Im not sure what my problem is but my fields are not populating. In my model I have a function that retrieves 3 records based on an id, and I call that function in my controller, which in turn should populate data in the view. I have tried to debug but have had no luck. I have tried to use die(debug($this->data)); but I when I run the script the next page loads instead of displaying what is in $this->data, which is strange to me! With that said, here is what I've got. Any input would be greatly appreciated! Thanks!Modelpublic function declinationsForPolicyId($id = null) {if ($id) {$items = $this->find('all', array('conditions' => array('Declination.policy_id' => $id),'limit' => 3,'contain' => array()));foreach ($items as $item) {$ret= $item['Declination'];}$ret = array('Declination' => $ret);}return $ret;}Controllerpublic function edit($id = null) {if (!empty($this->data)) {die(debug($this->data));$this->Declination->create();$this->data = $this->Declination->declinationsForPolicyId($id);if ($this->Declination->saveAll($this->data['Declination'])) {$this->Session->setFlash(__('Declinations saved.', true));$this->redirect(array('controller' => 'policies','action' => 'view',$id));} else {$this->Session->setFlash(__('Declinations failed to save.', true));}}$reasons = $this->Declination->Reason->find('list');$contactTypes = $this->Declination->ContactType->find('list');$this->set(compact('id', 'reasons', 'contactTypes'));}View<div class="content" id="container"><?php echo $this->UiForm->create('Declination', array('url' => array('controller' => 'declinations','action' => 'add',$id))); ?><?php for ($i = 0; $i < 3; $i++): ?><section class="panel"><h4>Declination <?php echo ($i + 1); ?></h4><?php echo $this->UiForm->input("Declination.{$i}.policy_id", array('type' => 'hidden','value' => $id)); ?><?php echo $this->UiForm->input("Declination.{$i}.id", array('type' => 'hidden')); ?><?php echo $this->UiForm->input("Declination.{$i}.first_name"); ?><?php echo $this->UiForm->input("Declination.{$i}.last_name"); ?><?php echo $this->UiForm->input("Declination.{$i}.company"); ?><?php echo $this->UiForm->input("Declination.{$i}.contact_type_id"); ?><?php echo $this->UiForm->input("Declination.{$i}.phone_number"); ?><?php echo $this->UiForm->input("Declination.{$i}.reason_id"); ?><?php echo $this->UiForm->input("Declination.{$i}.other", array('label' => 'If other, please supply a reason')); ?><?php echo $this->UiForm->input("Declination.{$i}.dated", array('type' => 'text','readonly' => 'readonly','data-datepicker' => '')); ?></section><?php endfor; ?><?php echo $this->UiForm->end(array('label'=>'Continue', 'class'=>'btn success large fr')); ?>--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment