简体   繁体   中英

symfony 1.4 - save dynamic values (choice form)

How can I get the values of a dynamic choice field and save them ?

This is my function :

public function configure()  
  {

    $query = FillableTable::getInstance()->createQuery('fal')->addWhere('0 = 1 ');

    $piecesChoices= RepaoTable::getInstance()->createQuery('rpo')->select('rpo.code_text')->execute();
    $choices = array();
    foreach ($piecesChoices as $choice) 
        {
    $value = $choice->getCodeText();
    $choices[$value] = $value;
        }



    $this->widgetSchema['simple1'] = new sfWidgetFormDoctrineChoice(array('model'=> 'Simple1'));
    $this->widgetSchema['simple2'] = new sfWidgetFormDoctrineChoice(array('model'=> 'Simple2', 'query' => $query));
    $this->widgetSchema['code_text']= new sfWidgetFormChoice(array(
            'expanded' => true,
            'multiple' => true,
            'choices'=> $choices
       ));


//validation 

    $this->validatorSchema....

//

I presume you are referring to saving the user-selected values from the code_text widget?

In your action, after the user POST/GETs your form you would have an array instead of a single value.

You can var_dump($request->getPostParameter('code_text')) to see what happens.

You can do whatever you want with those values then.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM