Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/291.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 带有两个字段的sfWidgetFormInputText的sfWidgetFormDate_Php_Symfony1_Widget_Symfony 1.4 - Fatal编程技术网

Php 带有两个字段的sfWidgetFormInputText的sfWidgetFormDate

Php 带有两个字段的sfWidgetFormInputText的sfWidgetFormDate,php,symfony1,widget,symfony-1.4,Php,Symfony1,Widget,Symfony 1.4,我有声明 $this->setWidget('one_date', new sfWidgetFormDate(array('format' => '%year% %month%' ))); MySQL中的一个日期是一个时间戳。这将显示带年份的选定列表和带月份的选定列表。如何更改月份的输入文本和年份的输入文本?如果尝试使用以下命令进行更改:sfWidgetFormInputText,则出现错误: sfWidgetFormInputText不支持 以下选项:“格式”, “年” 您需要

我有声明

$this->setWidget('one_date', new sfWidgetFormDate(array('format' => '%year%  %month%' )));
MySQL中的一个日期是一个时间戳。这将显示带年份的选定列表和带月份的选定列表。如何更改月份的输入文本和年份的输入文本?如果尝试使用以下命令进行更改:
sfWidgetFormInputText
,则出现错误:

sfWidgetFormInputText不支持 以下选项:“格式”, “年”


您需要在提交后合并两个单独的文本字段来创建一个日期。
这样做可能会使验证变得棘手

$this->setWidgets(array(
      'month' => new sfWidgetFormInputText(),
      'year' => new sfWidgetFormInputText()
   ));
$this->setValidators(array(
      'month' => new sfValidatorInteger(),
      'year' => new sfValidatorInteger()
      ));

谢谢,但是我有$this->setWidget('one_date',新的sfWidgetFormDate(数组('format'=>'%year%%month%'));而不是年复一年。我将分开小部件一个像日期一样的格式。。。在我的数据库里是一个日期字段(时间戳),也许我误解了你。我以为你想要两个文本输入字段,一个用于月,一个用于年?我实现这一点的方法是创建月份和年份的小部件,然后在验证之后将它们组合起来,以获得您的$one_日期值。
if ($this->form->isValid()) {
      $one_date = $this->form->getValue('month') . $this->form->getValue('year');
}