easyFormGenerator icon indicating copy to clipboard operation
easyFormGenerator copied to clipboard

Accessing dataModel outside of only the submit-form-event

Open vinnybod opened this issue 8 years ago • 0 comments

I should explain my use case. I essentially need two submit buttons. The first submit is to actually submit the form which they would not be able to go back and edit. The other is save which is to allow the user to save the data-model and come back to edit later on. I have made use of just repurposing the cancel-form-event to call my save method.

So almost everything works as I need it except the fact that I do not have access to the dataModel from the cancel form event.

In my mind I see two solutions,

  1. Have the eda-easy-form-viewer-data-model object two way binded
  2. Be able to submit the dataModel object to the cancel-form-event the same way we do for submit-form-event

I guess I also see a 3rd possibility - the ability to add custom buttons to the form

<eda-easy-form-viewer 
  eda-easy-form-viewer-data-model="demoCtrl.dataModel" 
  eda-easy-form-viewer-easy-form-generator-fields-model="demoCtrl.fieldsModel" 
  eda-easy-form-viewer-submit-button-text="{{demoCtrl.submitButtonText}}" 
  eda-easy-form-viewer-cancel-button-text="{{demoCtrl.cancelButtonText}}"
  eda-easy-form-viewer-submit-form-event="demoCtrl.submitFormEvent(dataModelSubmitted)" 
  eda-easy-form-viewer-cancel-form-event="demoCtrl.saveFormEvent(dataModelSubmitted)">
</eda-easy-form-viewer>

vinnybod avatar Jan 17 '17 23:01 vinnybod