Not too sure about that, but I would try something like:
$this->data['Transaction']['transaction_amount'] = $result;
On 16/08/2011 04:02, David Brotman wrote:
I have an input field in a form called transaction_amount and a select
field called transaction_type and a select field called tenant. What I
would like to do is populate the transaction_amount field with the
most recent transaction entry (transaction_date) for the selected
tenant where the transaction_type = 1 or transaction_type = 2. In this
scenario, I want the transaction_amount to be repopulated each time
the tenant is changed and each time the transaction_type is changed
between 1 and 2.
Form View:
<tr><th><?php __('Tenant');?></th><td><?php echo
$form->input('tenant_id',array('label'=>''));?></td></tr>
<tr><th><?php __('Transaction Type');?></th><td><?php echo
$form->input('transaction_type_id',array('label'=>''));?></td></tr>
<tr><th><?php __('Transaction Date');?></th><td><?php echo
$form->input('transaction_date',array('label'=>''));?></td></tr>
<tr><th><?php __('Amount');?></th><td><?php echo
$form->input('transaction_amount',array('label'=>'','class'=>'textsmall'));?>
In the transaction controller, I have a function to find the
transaction amount:
function getAmount()
{
$tenant_id = $this->data['Transaction']['tenant_id'];
$transaction_type = $this->data['Transaction']['transaction_type'];
$result = $this->Transaction->query("select transaction_amount from
transactions WHERE transaction_date =
(SELECT MAX(transaction_date) FROM transactions WHERE tenant_id =
\"$tenant_id\" and transaction_type = $transaction_type)");
$this->set('transaction_amount',$result);
}
Is this the right way to approach this problem? All of the examples on
the internet assume I am populating a select box. Any help would be
appreciated.
--
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and
help others with their CakePHP related questions.
To unsubscribe from this group, send email to
[email protected] For more options, visit this
group at http://groups.google.com/group/cake-php
--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php