Lakshitha Herath
Lakshitha Herath

Reputation: 638

cakephp dropdown list select and submit not working?

I'm using cakephp1.3 and i want to display a dropdown in a view.

<?php echo $this->Form->create('Ledger');?>
  <?php $userNames = $this->requestAction('users/getUsers'); ?>

  <fieldset>
    <legend><h2><?php __('Lend'); ?></h2></legend>
    <?php echo $this->Form->input('burID'); ?> <br>
    <?php echo $this->Form->input('displayname', array('type'=>'select','options'=>$userNames,'label'=>"Borrower",'empty'=>'Select name....')); ?><br>
    <?php echo $this->Form->input('amount');?> <br>
    <?php echo $userNames;?> <br>
  </fieldset>

<?php echo $this->Form->end(__('Submit', true)); ?>

it basically get users from Users database and display in a dropdown.Now i want to catch that selected name in the controller.but when i catch that from the controller it gives me the "displayname"(this is my fieldname which i imported to the drop down).How can i solve this?

Upvotes: 0

Views: 1018

Answers (1)

Alex
Alex

Reputation: 9471

In your controller, you shouldn't be going through

$displayname=$this->data['User']['displayname'];

Because you submitted the data through the form, you need to be retrieving data from through Ledger

$displayname = $this->data['Ledger']['displayname'];

Upvotes: 1

Related Questions