Hello everyone!
I am trying to create a login widget as selfcontained as possible, and I am facing some troubles while trying to manage validation errors. In general, I would have this problem with any form inside a widget view.
The login widget folder contains a LoginWidget class (extends CWidget), a LoginForm class (extends CFormModel) and a class LoginAction class (extends CAction) that handles the controller functionality (including a call to the validate method of the LoginForm object). The problems appear when there are validation errors, and the main page needs to be rendered again in order to show those errors to the user, since the widget doesn't have the control of the LoginForm instance anymore.
AFAIK, there are three possible ways to do it (excluding AJAX):
- In the run method of the widget I should call the validate method (double validation, since LoginAction also did it) using the $_POST['LoginForm'] information
- I should not use LoginAction to handle the validation functionality. The run method from the widget should do it, and when the page renders again it will detect the validation errors (or redirect to the private home page otherwise)
- LoginForm should be outside the widget directory, and the main page should pass an instance of the form via widget parameters.
I could have assumed some wrong premises and maybe I should consider other options
Could anyone show me the correct path?
Thanks in advance!
I am trying to create a login widget as selfcontained as possible, and I am facing some troubles while trying to manage validation errors. In general, I would have this problem with any form inside a widget view.
The login widget folder contains a LoginWidget class (extends CWidget), a LoginForm class (extends CFormModel) and a class LoginAction class (extends CAction) that handles the controller functionality (including a call to the validate method of the LoginForm object). The problems appear when there are validation errors, and the main page needs to be rendered again in order to show those errors to the user, since the widget doesn't have the control of the LoginForm instance anymore.
AFAIK, there are three possible ways to do it (excluding AJAX):
- In the run method of the widget I should call the validate method (double validation, since LoginAction also did it) using the $_POST['LoginForm'] information
- I should not use LoginAction to handle the validation functionality. The run method from the widget should do it, and when the page renders again it will detect the validation errors (or redirect to the private home page otherwise)
- LoginForm should be outside the widget directory, and the main page should pass an instance of the form via widget parameters.
I could have assumed some wrong premises and maybe I should consider other options
Could anyone show me the correct path?
Thanks in advance!