Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/259.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 Smarty html\u选择\u带有空字段的日期_Php_Smarty - Fatal编程技术网

Php Smarty html\u选择\u带有空字段的日期

Php Smarty html\u选择\u带有空字段的日期,php,smarty,Php,Smarty,我在使用smarty的html\u select\u日期自定义函数时遇到问题。在这里,我使用它在个人资料编辑页面上显示出生日期选择字段,大多数情况下它工作正常,但我的问题是当我试图告诉smarty将一个或多个字段设置为空值时。我有这个: {assign var="dateofbirth" value="`$errors['DOB']['year']`-`$errors['DOB']['month']`-`$errors['DOB']['day']`"} {html_select_date pre

我在使用smarty的html\u select\u日期自定义函数时遇到问题。在这里,我使用它在个人资料编辑页面上显示出生日期选择字段,大多数情况下它工作正常,但我的问题是当我试图告诉smarty将一个或多个字段设置为空值时。我有这个:

{assign var="dateofbirth" value="`$errors['DOB']['year']`-`$errors['DOB']['month']`-`$errors['DOB']['day']`"}
{html_select_date prefix="birthday" time=$dateofbirth start_year="-75" field_order="DMY" reverse_years="true" all_extra="onChange='saneDates()'" year_empty="Year" month_empty="Month" day_empty="Day"}
$errors数组是用PHP填充的——我的目标是构建一个字符串,正如文档所说,它可以通过省略缺少的值来指示空字段,例如“2013-12-”。这部分工作正常,我已经转储了输出,我正是这样设置的,但是smarty将day字段设置为“13”(即今天的日期),而不是我期望的空值


我遗漏了什么?

不能使用字符串时间值执行此操作。Smarty正在尝试创建有效的时间戳(有关详细信息,请参阅插件目录中的shared.make_timestamp.php)。当我查看function.html\u select\u date.php时,我注意到必须将time属性作为关联数组传递。数组键必须是前缀+年/月/日。我已经用一些虚拟数据(Smarty 3.1.15)对此进行了测试

{assign'dateofbirth'['birthdayear'=>$errors.DOB.year,'birthdayMonth'=>$errors.DOB.month,'birthdayDay'=>0]}


希望这有帮助

关于
“00-$errors['DOB']['month']-$errors['DOB']['year']]”
,它也会显示当前日期吗?不,这样做会生成一个字符串
“00-12-2013”
——这导致11月30日被生成(PHP的预期行为)。我必须解决这个问题,因为我有一个截止日期要满足,但如果有人能解释为什么smarty会这样做,我还是会悬赏的。这很公平。我以为我做得不对会很愚蠢。