thanks for the reply...i thought i had the logic down but it wasnt
showing any errors or warnings. I finally stumbled upon
a method that works--probably the way its supposed to be done. I moved
the logic from the controller to the model in a save method like this:

 public function save(Doctrine_Connection $conn = null) {

        $price = $this->getPrice();

        $taxRate = $this->calculateTax($price);
        $amnt = ($taxRate + $price);
        $this->setVat($taxRate);
        $this->setAmountWithVat($amnt);

        return parent::save($conn);
    }

using this method in the same class

 public function calculateTax($price) {

        $afterTax = $price * sfConfig::get('app_tax_rate');

        return $afterTax;
    }

and it worked.  Thanks for the reply anyway :-)
On 22 Jan, 09:46, Tom Ptacnik <to...@tomor.cz> wrote:
> 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 <sydneyari...@gmail.com> 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 <sydneyari...@gmail.com> 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 symfony-us...@googlegroups.com.
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en.

Reply via email to