?
Related to # 4654
Referenced as Related to: # 4654
avatar tranduyhung
tranduyhung
13 Oct 2014

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');
    }
}
avatar tranduyhung tranduyhung - open - 13 Oct 2014
avatar jissues-bot jissues-bot - change - 13 Oct 2014
Labels Added: ?
avatar zero-24 zero-24 - close - 14 Oct 2014
avatar jissues-bot
jissues-bot - comment - 14 Oct 2014
avatar jissues-bot jissues-bot - close - 14 Oct 2014
avatar brianteeman brianteeman - change - 14 Oct 2014
Status New Closed
Rel_Number 4654
Relation Type Related to
avatar jissues-bot jissues-bot - change - 14 Oct 2014
Closed_Date 0000-00-00 00:00:00 2014-10-14 07:31:14
avatar zero-24 zero-24 - change - 7 Jul 2015
Labels Added: ?

Add a Comment

Login with GitHub to post a comment