Skip to content
This repository has been archived by the owner on Nov 13, 2024. It is now read-only.

[UNDOCUMENTED? or NOT-SUPPORTED?] setting the form default value #99

Open
1 task done
sinisarudan opened this issue Jun 24, 2020 · 0 comments
Open
1 task done
Labels

Comments

@sinisarudan
Copy link

sinisarudan commented Jun 24, 2020

Environment

  • Hosting type

    • [] Form.io
    • Local deployment
  • Formio.js version: - Version: 4.9.26

  • Frontend framework: Angular 8+

  • Browser: Chrome

  • Browser version: Version 83.0.4103.116 (Official Build) (64-bit)

Steps to Reproduce

Expected behavior

to support group (collective) setting defaultValue for the form values .
as there is for the individual form component defaultValue setting`

Observed behavior

neither `this.tempFormContent.defaultValue =  formSavedData`

nor this.tempFormContent.defaultValues = formSavedData works

Is this not documented or not supported?

Example

<mat-formio [form]="projectFormContent" (submit)="onSubmit($event)"></mat-formio>

Individual setting to default value WORKS FINE:

protected tempFormContent:any = {
    "components": [
      {
        "label": "How do YOU define 1",
        "spellcheck": true,
        "tableView": true,
        "validate": {
            "unique": false,
            "multiple": false
        },
        "key": "key1",
        "type": "textarea",
        "input": true,
        "defaultValue": defValuekey1Saved,
        description: "...."
      },
      {
        "label": "How do YOU define 2",
        "spellcheck": true,
        "tableView": true,
        "validate": {
            "unique": false,
            "multiple": false
        },
        "key": "key2",
        "type": "textarea",
        "input": true,
        "defaultValue": defValuekey2Saved,
        description: "...."
      },
      {
        "type": "button",
        "label": "Save and Next",
        "key": "submit",
        "disableOnInvalid": true,
        "input": true,
        "tableView": false,
        "validate": {
            "unique": false,
            "multiple": false
        }
      }
    ]
  };

//returning the value used in the HTML template
public get projectFormContent():any {
    return this.tempFormContent;

BUT is there some group default setting, I've tried this, but NOT working:

protected tempFormContent:any = {
    "components": [
      {
        "label": "How do YOU define 1",
        "spellcheck": true,
        "tableView": true,
        "validate": {
            "unique": false,
            "multiple": false
        },
        "key": "key1",
        "type": "textarea",
        "input": true,
        // "defaultValue": defValuekey1Saved,
        description: "...."
      },
      {
        "label": "How do YOU define 2",
        "spellcheck": true,
        "tableView": true,
        "validate": {
            "unique": false,
            "multiple": false
        },
        "key": "key2",
        "type": "textarea",
        "input": true,
        // "defaultValue": defValuekey2Saved,
        description: "...."
      },
      {
        "type": "button",
        "label": "Save and Next",
        "key": "submit",
        "disableOnInvalid": true,
        "input": true,
        "tableView": false,
        "validate": {
            "unique": false,
            "multiple": false
        }
      }
    ]
  };

//returning the value used in the HTML template
public get projectFormContent():any {
    this.tempFormContent.defaultValue =  {'defValuekey1':defValuekey1Saved, 'defValuekey2':defValuekey2Saved};
   // this neither works:
   // this.tempFormContent.defaultValues =  {'defValuekey1':defValuekey1Saved, 'defValuekey2':defValuekey2Saved};
    return this.tempFormContent;
@sinisarudan sinisarudan changed the title [UNDOCUMENTED] setting the form default value [UNDOCUMENTED? or NOT-SUPPORTED?] setting the form default value Jun 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant