Skip to content

Creating a form from a JSON results in a broken form if no field IDs specified #11

@amielucha

Description

@amielucha

The following command results in a successful form addition but when editing the form fields in the WP admin, the fields' details don't expand.

WP-CLI command: wp gf form create --form-json='FORM_JSON_GOES_HERE'

When trying to expand a field in the admin panel the following error is printed to the console:

TypeError: form.fields[b] is null

This is due to the inputs in my JSON not including field IDs.

Example field in my JSON (this doesn't work):

{
    "type": "text",
    "label": "Name",
    "defaultValue": "",
    "visibility": "visible",
    "isRequired": true,
    "size": "large"
},

When I add IDs manually to the import, the form functions correctly:

{
    "type": "text",
    "label": "Name",
    "defaultValue": "",
    "visibility": "visible",
    "isRequired": true,
    "size": "large",
    "id": 1
},

Requested change

Would it be possible to auto-assign consecutive field IDs on import?

Environment

WP Version: 4.9.8
GF Version: 2.3.4.3
GF-CLI Version: 1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions