Try to debug if processTax() is executed ie. simply do echo "I'm here";exit; or something like that. And when you will be sure that it isn't executed or it's executed, then do some more ...
On 21 led, 21:46, el-sid <[email protected]> wrote: > ive modified the code in the controller so that it can set the > parameters before create or update > like so > > private function processTax(sfWebRequest $request) { > > $price = $request->getParameter('price'); > $mystock = new Stock(); > $taxRate = $mystock->calculateTax($price); > > $request->setParameter('vat', $taxRate); > $request->setParameter('amount_with_vat', ($taxRate+$price)); > } > > public function executeCreate(sfWebRequest $request) { > > $this->processTax($request); > > $this->form = $this->configuration->getForm(); > $this->stock = $this->form->getObject(); > > $this->processForm($request, $this->form); > > $this->setTemplate('new'); > } > > public function executeUpdate(sfWebRequest $request) { > > $this->processTax($request); > > $this->stock = $this->getRoute()->getObject(); > $this->form = $this->configuration->getForm($this->stock); > > $this->processForm($request, $this->form); > > $this->setTemplate('edit'); > } > > i dont get any error when i do this but the processTax function does > not seem to execute since i > dont find the values in the db. Any ideas? > > On 21 Jan, 23:28, el-sid <[email protected]> wrote: > > > > > hi, > > basically what i'm trying to do is hide two fields from the form Stock > > in the admin then when the user is creating or editing a new stock > > object. there is some background calculation that is done then passed > > as a request before the form is processed. > > > The code am trying to process is this in > > /lib/model/doctrine/Stock.class > > > public function calculateTax($price) { > > > $afterTax = $price * sfConfig::get('app_tax_rate'); > > > return $afterTax; > > } > > > i then pass this function to a stockActions class using this code > > > public function executeUpdate(sfWebRequest $request) { > > $this->stock = $this->getRoute()->getObject(); > > $this->form = this->configuration->getForm($this->stock); > > > $price = $request->getParameter('price'); > > > $mystock = new Stock(); > > $taxRate = $mystock->calculateTax($price); > > > $request->setParameter('vat', $taxRate); > > $request->setParameter('amount_with_vat', ($taxRate+$price)); > > > $this->processForm($request, $this->form); > > > $this->setTemplate('edit'); > > } > > > what am trying to do is overide the default update function by getting > > and calculating the appropriate parameters before the form is > > processed. However, the values am calculating are not being processed > > with the form. > > > what am i doing wrong? or is there another way to do this? > > > Thanks -- You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en.
