2012-09-10 37 views

回答

0

你試過這種方式嗎? 創建類

class YourForm extends sfForm { 
    $array= array('array'); 
    $this->setWidgets(array(
      'field1' => new sfWidgetFormSelect(array('choices' => $array), array('placeholder' => 'field1', 'required' => 'true', 'data-empty' => 'U did not enter field1!')), 
      'email_address' => new sfWidgetFormInputText(array('type' => 'email'), array()) 
    )); 
} 

你甚至可以改變第一陣列中的類型。然後包括在行動窗體調用它像

$this->form = new YourForm(); 

然後回顯表單模板:

<?php echo $form; ?> 

我希望這有助於。我也是這樣使用它,以添加額外的屬性在JavaScript中使用。

相關問題