Quantcast

id field truncated when retrieved from drop down

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

id field truncated when retrieved from drop down

Shosho
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>

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: id field truncated when retrieved from drop down

Tilen Majerle
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 <[hidden email]>
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 [hidden email].
To unsubscribe from this group, send email to [hidden email].
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 [hidden email].
To unsubscribe from this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: id field truncated when retrieved from drop down

Shosho
*FACE PALM* For the love of- You sir, are amazing. XD For some reason I thought I had to reference that specific field when I tried to call it. Not sure why, I think originally I had it setup so that a different view used that function? Who knows. Thank you so very much.
Loading...