0
votes

I have a variable that is set to session from the action form. I need to access the variable in the form How can i do it? This is the code I am going to access the variable.

    $this->unitCost = $this->getUser()->getAttribute('unit_cost');
    //assign variable to session value
    $value_lists = ($this->unitCost);
    //select value from foreach
    print_r($value_lists);
    foreach($value_lists as $values)
    {
        $newValue = $values['unit_cost'];
    }

I want to access this $newValue any where in the form

I want to use this code inside the public function configure() { }in sFform where the widgets are defined. how Can I do it? Please help me in this.. Thank you very much

1

1 Answers

1
votes

When you call your form you can set it variables like this :

$this->form = new YourForm(null, array('Myvalue' => $newValue));

and get it in your form like this:

$newValue = $this->getOption('Myvalue');