0

如何获取动态选择字段的值并保存它们?

这是我的功能:

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....

//
4

1 回答 1

0

我想您指的是从小code_text部件中保存用户选择的值?

在您的操作中,在用户发布/获取您的表单后,您将拥有一个数组而不是单个值。

你可以var_dump($request->getPostParameter('code_text'))看看会发生什么。

然后,您可以对这些值做任何您想做的事情。

于 2012-10-23T18:47:00.273 回答