Developer forum

Forum » Development » Prevent form from saving

Prevent form from saving

Aki Ruuskanen
Reply

Hi,

How can I prevent a form from getting saved? Can the FormSaveProvider be used for this? 

Regards / Aki

 

 

 


Replies

 
Nicolai Høeg Pedersen
Reply

Hi Aki

 

In forms for datalist, you cannot I believe...

 

But you can create a formsave provider that will delete the just saved record - the form will first be saved and then form save providers are executed, so it should be possible.

 

BR Nicolai

 
Nuno Aguiar
Reply

Hi,

 

Yes, it is possible to delete the record; we use it all the time. Although it would be nice if there was a subscriber onBeforeSave. We sometimes want to manipulate data, and cannot that :(

 

Nuno

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

+1 I very much agree. That way, you can implement your own validation logic without implementing your own save and e-mail functionality.

 

As an alternative it would be nice if:

 

1. Returning False from the Save method of your own SaveProvider (or some other status flag) would stop DW from calling the other providers.

2. You could change the order they are called in. That way your validation module would go first. When something is wrong, you return False and the rest of the providers are never executed.

 

One thing you *could* do (not necessarily recommending you should) is this:

 

1. Create your own provider

2. Inside the save method, instantiate one of the existing providers. Set public properties (which you'll need to replicate on your own provider) and call Save

3. Configure your own provider only in DW.

 

I haven't tested this or looked at the implementation, but it might be worth looking into.

 

Cheers,

 

Imar

 
Nicolai Høeg Pedersen
Reply

Will look into that. TFS#13804

 

You should be able to control the order by using AddInOrder attribute on your form save providers. Set it to -1 to bubble on top of the others. In theory it should Work.

 

BR Nicolai

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Ah, yes, that's what I thought but I wasn't sure. I recall trying it once and then it didn't shoe up in the UI as the first item, leading me to believe that it doesn't work. But maybe it's unrelated.

 

Thanks!

 

Imar

 

You must be logged in to post in the forum