how to give dummy values to formio form

本秂侑毒 提交于 2020-04-05 06:54:18

问题


I have created a username and password with submit button page using formio

and I have shown in the page by taking that script from the database. the page is visible now. But I want to show a dummy username and password when I click on a button.

But I have achieved like whenever the page loads the data will fill by adding below.

    <formio [form]="obj"[submission]='{
        "data": {
          "userName": "Joe",
          "password": "Smith"
        }
      }'>

But I want to fill the data when I have clicked on a button. Actually my intention is that I want to access that username in my component. How can I access that username

Ex:- In angularJS, we can access that with ng-model like $scope.ngModel in formio how can we access that in a component.


回答1:


Yes, we can achieve this in component level even.

change your html as below

<formio [form]="obj" [submission]="submission"/>

add the following in your component

submission: any;

    showData () {
        this.submission = {
          data: {
              userName: 'Joe',
              password: 'Smith'
          }
        };
      } 

it should display the data in page.

Happy coding :)



来源:https://stackoverflow.com/questions/60650006/how-to-give-dummy-values-to-formio-form

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!