Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can we use custom JSON format to generate forms? #2708

Closed
avifox opened this issue Feb 18, 2021 · 1 comment
Closed

Can we use custom JSON format to generate forms? #2708

avifox opened this issue Feb 18, 2021 · 1 comment

Comments

@avifox
Copy link

avifox commented Feb 18, 2021

I am using the angular ngx-formly library to generate dynamic forms. I am following this example: https://stackblitz.com/angular/bxpovqrjjql?file=src%2Fapp%2Fapp.component.ts

The code makes use of a JSON format as below:

[
{
"key": "firstName",
"type": "input",
"templateOptions": {
"label": "First Name"
}
},
{
"key": "lastName",
"type": "input",
"templateOptions": {
"label": "Last Name"
}
},
{
"key": "mac",
"type": "input",
"templateOptions": {
"label": "Mac Address",
"pattern": "([0-9A-F]{2}[:-]){5}([0-9A-F]{2})"
}
},
{
"key": "color",
"type": "input",
"templateOptions": {
"label": "Color Preference (try this out)"
}
},
{
"key": "reason",
"type": "textarea",
"templateOptions": {
"label": "Why?"
},
"expressionProperties": {
"templateOptions.label": "'Why did you choose ' + model.color + '?'"
},
"hideExpression": "!model.color"
}
]
I need to use a different type of JSON as per below:

    "fields": [
        {
            "index": 0,
            "label": "First Name",
            "type": "text",
            "placeholder": "Enter First Name",
            "employeeMapping": {
                "section": "Employee",
                "key": "firstName"
            }
        }
    ]

Is this feasible with formly or do we need to use the standard JSON format provided?

@aitboudad
Copy link
Member

see #1982 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants