In a Cakephp v2.3 App, there are two models:
Purchase Model: it contains the following main fields: id, invoice_date & gross_amount(calculated on Supplier.tax_rate).
class Purchase extends AppModel {
public $displayField = 'id';
public $belongsTo = 'Supplier';
}
Supplier Model: it contains id, name & tax_rate
class Supplier extends AppModel {
public $displayField = 'name';
public $hasMany = 'Purchase';
}
This is how my Add view of PurchasesController Looks:

Now, I want to get Supplier.tax_rate of currently selected supplier displayed In app/View/Purchase/add.ctp as label or text input.
Any idea how to do this?
I figured it out.
What, I ended up doing was putting all supplier tax rate data as
JSON, outputting that into the view & then using client-side javascript to select the relevant code.PurchasesController calls a custom model method which fires up a SQL query to get all supplier tax rate data.
The, in the client-side. I used Javascript to do what I wanted, here
supplier_tax_ratesis the variable which stored JSON tax rate data &getTaxRateis a variable function which returns tax rate from JSON based onidfrom supplier downdown.This has worked nicely for me, Hope it helps other people who want to get some data from database in cake, based on the value of dropdown.