Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

MoeSaid's avatar

prevent forms from working

Hi ,

am creating a project and i wanna put a demo for users to test , however they will have access to the admin aria , i want to prevent any form with post method of working , i did that with javascript by prevent the default methods , i was wondering if there a better way to do so , in case the javascript never loaded .

0 likes
2 replies
petrit's avatar

You may use conditions on views in order prevent forms from acting normally. You may check if the user level is demo change action attribute from form. Also you may use middleware in order to prevent your controllers being executed from demo users.

1 like
MoeSaid's avatar

@PETRIT - i was going to work with the view and the controller but its hussle when the project is big , doing it with a middleware is the best thing to go with in my opinion but i still couldn't reach is logic , what would you recommend how the logic of its function looks like .

Please or to participate in this conversation.