【问题标题】:How to implement radio button in autoform meteorJS如何在 autoform meteorJS 中实现单选按钮
【发布时间】:2016-04-21 14:40:52
【问题描述】:

架构

 Color : {
optional: true,
autoform: {
  type: "select-radio",
  options: function () {
    return [
      {label: "orange", value: orange},
      {label: "blue", value: blue},
      {label: "red", value: red}
    ];
  }
}

}

HTML 页面:

{{> afFormGroup name="Color" type="select-radio" options=options}}

复选框按钮不显示,我做错了什么?

【问题讨论】:

    标签: meteor meteor-autoform


    【解决方案1】:

    您还需要为您的架构字段指定一个类型。不仅仅是自动表单字段。试试这个:

    Color: {
        optional: true,
        type: String,
        autoform: {
            type: "select-radio",
            options: function() {
                return [{
                    label: "orange",
                    value: orange
                }, {
                    label: "blue",
                    value: blue
                }, {
                    label: "red",
                    value: red
                }];
            }
        }
    }
    

    【讨论】:

      【解决方案2】:

      如果您想节省一些输入,另一种选择是这样做(请原谅咖啡脚本)

      color:
        type: String
        allowedValues: ['Red', 'Blue', 'Orange']
        autoform:
          type: 'select-radio'
      

      【讨论】:

        【解决方案3】:

        您的 html 助手是错误的。实现这一目标的正确方法是

        {{> afFormGroup name="Color" type="select-radio" }}
        

        请注意,我刚刚从您的原始代码中删除了“options=options”

        {{> afFormGroup name="Color" type="select-radio" options=options}}
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2015-10-18
          • 2015-10-31
          • 2017-01-21
          • 2020-11-19
          • 1970-01-01
          • 2012-08-31
          • 2017-05-23
          • 2015-01-18
          相关资源
          最近更新 更多