Skip to content

How to push error to FormController? #919

Answered by cpaschen
cpaschen asked this question in Q&A
Discussion options

You must be logged in to vote

Found a better solution.

In the php before_save custom code area for this admin view, in the if section that checks for the valid file uploads, I have added the following code:

$errormsg = JText::sprintf('COM_MY_COMPONENT_ALERT',$data['name']);
$app = JFactory::getApplication();
$app->enqueueMessage($errormsg,'error');
$formURL = '/component/COMPONENT_NAME/VIEW_NAME?layout=edit';
$app->redirect(JRoute::_($formURL, false));

Now, when the error condition is met, the user is automatically re-directed back to the form and the custom enqueueMessage is displayed, and nothing else.

I'm still working on how to have any entered data maintained on the form using session variables and something lik…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by cpaschen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant