angular-schema-form icon indicating copy to clipboard operation
angular-schema-form copied to clipboard

allow more fine-grained control of destroy strategy

Open donalmurtagh opened this issue 8 years ago • 1 comments

Currently, the destroy strategy for conditional fields can only be specified at the form level, but it would be useful if you could have different strategies for different fields.

In our case, we use conditions to implement pagination-like behavior:

    {
      type: 'section',
      condition: 'model.page === 1',
      items: [
        'field1',
        'field2'
      ]
    },
    {
      type: 'section',
      condition: 'model.page === 2',
      items: [
        'field3',
        'field4'
      ]
    }

At the bottom of the form there are previous/next buttons which update the value of model.page. Obviously we never want to remove the data when the users moves to a different page, so we have to use a form-wide destroy strategy of retain.

What we like to be able to do is use a retain destroy strategy for the page conditions and a remove destroy strategy for the fields within the pages.

donalmurtagh avatar Mar 23 '17 16:03 donalmurtagh

@donalmurtagh well wizards are a case discussed already and there is an issue for them somewhere, my goal for 1.x is to add state support, where another model could be added to the form to act as state and then you could append that to URIs or within a post body etc... without adding details to the form that shouldn't need to be in the model scope.

Another goal is to have conditions available out of the main ui-schema in a set of rules that can be applied to all matching fields.

Anthropic avatar Apr 02 '17 12:04 Anthropic