Joomla 5 Notice

We are pleased to announce that as of January 29, 2024, all of our Joomla extensions are compatible with Joomla 5.

For all who are still updateing from Joomla 3 to Joomla 4: Joomla 4 Migration instructions are available here:

There is now a separate Documentation for Visforms for Joomla 4 and for Visforms for Joomla 5!

Forum

Visforms Subscription user can ask questions in our forum. Please log in with the relevant user first.
Everybody can access the forum for reading.

Please only ask 1 question per topic.

Error message in Default Joomla "system-message"

More
7 years 8 months ago #3500 by ttome
Hi, all!
I have no idea how to fix my problem! :(
May be some one can help me...

So, i have Yootheme, with default Uikit Modal component . The same time i using free Regular Labs plugin Modules Anywhere . So i can put my Visform module into modal. It's work great with form sending, but i found a small problem with Error message!..

When i using "Upload file" input with custom settings (for example: file format must be only png) i get an Error message when trying to upload file in jpg. This is all good, but i get this message in my modal, NOT IN Default Joomla! System Message Container!

So i found this code:
Code:
<?php if (isset($visforms->errors) && is_array($visforms->errors) && count($visforms->errors) > 0) { $layout = new JLayoutFile('visforms.error.messageblock', null); $layout->setOptions(array('component' => 'com_visforms')); $html = $layout->render(array('errormessages' => $visforms->errors, 'context' => 'form')); echo $html; } ?>

It displays next code in my Form block:
Code:
<div class="alert alert-danger"> <button class="close" data-dismiss="alert" type="button">×</button> <h4 class="alert-heading">Title</h4> <p>Text.</p> </div>

Now I break my head HOW TO replace this message into Default Joomla! System Message Container??? :S

PS
Sorry for my English

Thank You

More
7 years 8 months ago #3501 by Administrator AV
Replied by Administrator AV on topic Error message in Default Joomla "system-message"
Hi,

Visforms can be used with a module, displayed inside an article or published via a menu item and it is actually possible to have multiple forms on one page and you can display a form in a modal window using the component.php ( www.vi-solutions.de/en/documentations/vi...rm-in-a-modal-window ) which is a common way in Joomla! to only display the component. If the server side form validation fails and you have used any of the ways to display the form, the form will be displayed again and the user inputs, which were already made, are used inside the form. Further on, Visforms displays error messages then.

I decided on displaying the error messages inside the form, using the standard Joomla! HTML tags and classes as for the system message, in order to make sure, that the error messages are always displayed and are always near the form (with component.php in a modal window, the messages would not be visible and with multiple forms on one site, it could be confusing, if the message are apart from the form).

Nevertheless, the error messages are created by a Visforms layout file, which can be overriden in your template. The layout file - messageblock.php - is located at components\com_visforms\layouts\visforms\error. Create a copy of this file in templates\yourTemplate\html\layouts\com_visforms\visforms\error

Replace the following code from the override file
Code:
$html .= '<div class="alert alert-danger">'; $html .= '<button class="close" data-dismiss="alert" type="button">×</button>'; if (!empty($displayData['context'])) { switch($displayData['context']) { case 'dataeditform': $html .= '<h4 class="alert-heading">' . JText::_('COM_VISFORMS_EDIT_FORM_HAS_ERROR') . '</h4>'; break; default: $html .= '<h4 class="alert-heading">' . JText::_('COM_VISFORMS_FORM_HAS_ERROR') . '</h4>'; break; } } else { $html .= '<h4 class="alert-heading">' . JText::_('COM_VISFORMS_FORM_HAS_ERROR') . '</h4>'; }
with
Code:
$app = JFactory::getApplication();

In the foreach statement replace
Code:
$html .= '<p>' . $errormessage . '</p>';
with
Code:
$app->enqueueMessage($errormessage, 'error);
delete the line
Code:
$html .= '</div>';

I think this is roughly what you want to do.

Regards,
Aicha

:idea: I recommend you the new and up-to-date documentation for Joomla 4:
docs.joomla-5.visforms.vi-solutions.de/en/docs/
Most of this also applies retrospectively to Joomla 3.
Please only ask 1 question per topic :-).

:idea: Ich empfehle Dir die neue und aktuelle Dokumentation für Joomla 4:
docs.joomla-5.visforms.vi-solutions.de/docs/
Das meiste gilt rückwirkend auch für Joomla 3.
Bitte immer nur 1 Frage pro Thema stellen :-).

Moderators: Administrator AVAdministrator IV
Powered by Kunena Forum