You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

TYPO3 EXT:femanager添加下拉选择字段遇类型错误求助

问题解决:femanager自定义下拉字段报错处理

报错信息

The argument "options" was registered with type "array", but is of type "string" in view helper "In2code\Femanager\ViewHelpers\Form\SelectViewHelper".

问题场景

在TYPO3 V11.5.37 + femanager 7.3.1环境下,扩展femanager自定义字段时添加用户类型下拉选择框,出现上述错误,当前模板调用代码:

<femanager:form.select
  id="femanager_field_usertype"
  property="userType"
  options="{1:private, 2:business, 3:real estate agent}"
  defaultOption="{f:translate(key:'pleaseChoose')}"
  class="form-control"
  additionalAttributes="{femanager:Validation.FormValidationData(settings:settings,fieldName:'userType')}" />

解决方案

错误根源是options参数被解析成了字符串,而非要求的数组类型。在Fluid模板中,数组的字符串值必须用单引号包裹,否则会被识别为变量或无效语法。修改后的代码如下:

<femanager:form.select
  id="femanager_field_usertype"
  property="userType"
  options="{1:'private', 2:'business', 3:'real estate agent'}"
  defaultOption="{f:translate(key:'pleaseChoose')}"
  class="form-control"
  additionalAttributes="{femanager:Validation.FormValidationData(settings:settings,fieldName:'userType')}" />

仅需给每个选项值添加单引号',即可让Fluid正确解析为数组类型。

内容的提问来源于stack exchange,提问作者webman

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.22 21:24:50