0

我是 symfony 框架的新手。我在一个已经存在的项目上工作过,所以我想使用 symfony 1.2 将选择框更改为文本框。

4

1 回答 1

0

更多信息和代码片段会有所帮助,但是..

有几个地方可以做到这一点,我会选择最直接和最常见的两个。

1) 您的表单已经过定制,很可能会在plugins/yourPlugin/lib/form/yourForm.class.php

在这里会有类似的东西$this->setWidget('my_input', new sfWidgetChoice(array([...])));

它可能有许多“选择”小部件(如果它们来自数据库,则为 Doctrine 或 Propel)

您需要将其更改为$this->setWidget('my_input', new sfWidgetFormInput());

2)你的表单之前没有修改过,是生成的表单

您将需要进入您的actions.class.php(或components.class.php)并找到它说的位置$this->form = new yourForm();

制作一个新表格plugins/yourPlugin/lib/form并使其扩展您以前的表格。

class yourNewForm extends yourForm

然后加

public function setup()
{
 $this->setWidget('my_input', new sfWidgetFormInput());
}

您可能还必须更新验证器,否则它将需要“选择框”格式的数据。

http://www.symfony-project.org/api/1_1/sfWidgetFormInput

于 2012-10-23T20:11:53.417 回答