开发者

form widgets values

I have used form widgets for my user registration which has sales or customer radio buttons If customer button is checked means i have to insert into registration table and one more table also. So i want to use the form submitted values before executing $form->save();. How to do this.Pl help me......

My radio button field name is executive_check

protected function processForm(sfWebRequest $request, sfForm $form)
{
   $form->bind($request->getParameter($form->get开发者_C百科Name()),$request->getFiles($form->getName()));
    if ($form->isValid())
    {
//i have to check the form user type radio button value here
        $form->save();
    }
    else
    {
        echo "Error";
    }
}

Please help me........


In my opinion, you should override save method on your form, and do not change anything on your actions.

For example:

class BookForm extends BaseBookForm {
    public function save($con = null) {
        if($this->getValue('isCustomer')) {
            // do your additional save  
        }
        return parent::save();
    }
}


If you want to access posted variable from the form you have to overwrite the save() function in your registration form and you can access all of the post variables in one array with name "$this->values". Please try like below

public function save($con = null){

 // This will list out whole array of the posted variables.
 echo "<pre>";
 print_r($this->values);

// to use your field variable with named "executive_check" you can get value by below syntax

if($this->values['executive_check'] == 'radiobuttonValue'){
  // your logic if sales or customer radio button is selected.
 }
  // will call parent form save function to save all data
 parent::save($con);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜