Tuesday, September 25, 2012

Re: id field truncated when retrieved from drop down

why  $this->data['Drug']['DrugList']['id']  ?

it's just  $this->data['Drug']['DrugList'] if i'm sure what i see here...sorry if i missed :)
--
Lep pozdrav, Tilen Majerle



2012/9/25 Shosho <shinsuio0012@gmail.com>
I've been hitting a wall concerning this problem for a few days now. In my
app I'm trying to generate a report based on a choice chosen from a drop
down. The dropdown displays the fields correctly, hides the id and shows the
name field(the ID's are correct in the dropdown, I checked). When an option
is selected and submit is clicked, it appears as though the ID is changed to
just the first number. So if the ID is originally 2044, then it becomes 2, I
have no idea why. The view and controller function look right to me. Any
ideas?

*Controller Function:*
  function report(){
    $this->set('alldrugs', $this->Drug->find('list', array(
      //'cache' => 'drugList',
      //'cacheConfig' => 'sql',
      'fields' => array('id', 'generic'),
      'order' => 'Drug.generic',
      'recursive' => -1,
    )));
    if (!empty($this->data['Drug'])) {
//debug($this->data['Drug']['DrugList']['id']);

$this->Session->setFlash(sprintf($this->data['Drug']['DrugList']['id']));
//$this->redirect(array('controller'=>'drugs','action'=>'generatePatientInfo',$this->data
['Drug']['DrugList']['id']));
      }
  }

*View:*
<div><?php echo $form->create('Drug');?>
  <fieldset>
    <legend><?php printf('Calls for Generic Report'); ?></legend>
  <?php
    echo $form->input('DrugList', array('type' => 'select', 'id' =>
'DrugList', 'label' => 'Select generic drug:',
      'empty' => 'Select', 'options' => $alldrugs)
    );
    echo '<br />NOTE: Select a drug above to generate a list of patients who
called about it.' .
          '<br/>' . 'The report will need to be imported into Excel.';
    echo $form->end(__('Submit', true));
  ?>
  </fieldset>
</div>





--
View this message in context: http://cakephp.1045679.n5.nabble.com/id-field-truncated-when-retrieved-from-drop-down-tp5711358.html
Sent from the CakePHP mailing list archive at Nabble.com.

--
Like Us on FacekBook 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 post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.



--
Like Us on FacekBook 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 post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 

No comments: