Susticle Posted July 30, 2018 Share Posted July 30, 2018 Hi, I wrote a little module which determines the value for an read-only inputfield depending on two other required text fields. If the necessary value cannot be found, saving should be prohibited but the entered values should stay in there. I used the hook "ProcessPageEdit::processInput" as described here and almost everything works fine. But there is one thing: The values are saved even if I detected an error. Is there a way to prevent this? I tried the hook "saveReady" but then the given values are lost in case of errors. Thanks! Link to comment Share on other sites More sharing options...
elabx Posted July 31, 2018 Share Posted July 31, 2018 What if you set the hook to happen before? Link to comment Share on other sites More sharing options...
Robin S Posted July 31, 2018 Share Posted July 31, 2018 11 hours ago, Susticle said: If the necessary value cannot be found, saving should be prohibited but the entered values should stay in there. That would be difficult to do as it goes against the way ProcessPageEdit works normally - when PPE loads, the values shown in the inputfields are the values stored in the database. So it also raises the question of even if you could do it (maybe save the $input->post data to $session and then hook the inputfield render to load custom content to the inputs) whether it would be a good idea given that it goes against what PW editors will be used to. You might be better to disable the save button with Javascript if the required fields are not filled out. Note also that for text fields there is a setting to use the HTML5 required attribute which has the effect of preventing a page save when the required field is not filled out. With either of these approaches though you should consider how you will handle an attempted save from a PPE tab other than Content (e.g. an attempted save from the Settings tab). 1 Link to comment Share on other sites More sharing options...
Susticle Posted August 9, 2018 Author Share Posted August 9, 2018 Thanks for the answers. After discussing this we changed some things, now the way described above is appropriate. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now