While building a custom JFormRule to validate the options in my custom component's configuration, I realize that the rule's error message is not displayed after redirecting back to the configuration form.
class JFormRuleFoo extends JFormRule
{
public function test(SimpleXMLElement $element, $value, $group = null, JRegistry $input = null, JForm $form = null)
{
// Validation fails, enqueue error message, it must be displayed when we are taken back to the form.
JFactory::getApplication()->enqueueMessage(JText::_('Validation fails'), 'warning');
return false;
}
}
But if we try to go to somewhere else
JFactory::getApplication()->enqueueMessage(JText::_('test'), 'warning');
JFactory::getApplication()->redirect('index.php');
Then the message is displayed as usual.
The problem is in https://github.com/joomla/joomla-cms/blob/staging/components/com_config/model/form.php#L313
It should be
foreach ($form->getErrors() as $message)
{
if ($message instanceof Exception)
{
JFactory::getApplication()->enqueueMessage($message->getMessage(), 'error');
}
else
{
JFactory::getApplication()->enqueueMessage($message, 'error');
}
}
Labels |
Added:
?
|
Status | New | ⇒ | Closed |
Rel_Number | ⇒ | 4654 | |
Relation Type | ⇒ | Related to |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2014-10-14 07:31:14 |
Labels |
Added:
?
|
Set to "closed" on behalf of @brianteeman by The JTracker Application at issues.joomla.org/joomla-cms/4653