formio / formio.js

JavaScript powered Forms with JSON Form Builder

Home Page:https://formio.github.io/formio.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Select field in datagrid displays "[object Object]" when rendering read-only

tolbertncsa opened this issue · comments

Create a datagrid with a child component of type "select" and widget "choicesjs".
Rendering this form in editable mode will work correctly.
Rendering this form in read-only mode will display "[object Object]" instead of using the template value to format the object.

Expected behavior: the read-only view would display the templated label instead of [object], as the Select widget does when NOT in a datagrid.

My form definition for this component:

   {
      "label": "New Funding",
      "reorder": false,
      "addAnotherPosition": "bottom",
      "layoutFixed": false,
      "enableRowGroups": false,
      "initEmpty": false,
      "tableView": false,
      "key": "newFunding",
      "type": "datagrid",
      "input": true,
      "components": [
        {
          "label": "CFOPA",
          "widget": "choicesjs",
          "placeholder": "Select CFOPA",
          "tableView": true,
          "dataSrc": "url",
          "data": {
            "url": "/autocomplete/cfopa",
            "headers": [
              {
                "key": "",
                "value": ""
              }
            ]
          },
          "idPath": "cfopa_id",
          "template": "<span>{{ item.chart }}-{{ item.fund }}-{{ item.org }}--{{item.program}}--{{item.activity}} {{item.activity_name}}</span>",
          "validate": {
            "select": false
          },
          "key": "cfopa",
          "type": "select",
          "selectValues": "result",
          "disableLimit": false,
          "searchField": "search",
          "input": true
        },
        {
          "label": "Percent",
          "description": "Percent FTE",
          "key": "percent",
          "type": "textfield",
          "input": true,
          "tableView": true


        }
      ]
    },

readOnlyMode

editableMode

Yes I agree this is a bug. It must have something to do with the "renderValueAsString" method call for the Select component. Is this something that maybe you are able to debug and propose a change? If so, we will happily review it and include your fix for the 5.x version we are working on. If not, then it will probably go into our internal Form.io developer queue, which is pretty long at the moment.