gpt4 book ai didi

php - Symfony2,如何向表单添加隐藏的日期类型字段?

转载 作者:可可西里 更新时间:2023-10-31 23:52:08 25 4
gpt4 key购买 nike

我正在尝试以下场景:

myclassType

public function buildForm(FormBuilder $builder, array $options)
{
$builder
->add('day','hidden')
->add('date', 'hidden' )
->add('hours')
->add('comment','textarea')
;
}

myclass

class myclass
{
//.. Other stuff

/**
* @ORM\Column(type="date")
*
* @var date $date
*/
protected $date;
}

渲染时出现此错误:

An exception has been thrown during the rendering of a template ("Catchable Fatal Error:
Object of class DateTime could not be converted to string in
C:\wamp\www\PMI_sf2\app\cache\dev\twig\fb\40\8957f80f2358a6f4112c3427b387.php line 684") in
form_div_layout.html.twig at line 171.

知道如何隐藏日期类型字段吗!??

最佳答案

表格

$builder
->add('day','hidden')
->add('date',null,array( 'attr'=>array('style'=>'display:none;')) )
...

关于php - Symfony2,如何向表单添加隐藏的日期类型字段?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10709773/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com