This has probably already been gone through but I just figured it out so....
If you want to validate a bunch of things in PHP (serverside) and have it display helpful messages.
1. Add a PHP action under setup. For example:
[strong]Name: customValidation
[/strong][pre][strong]$valMessage = [ ];
if(empty($this->data("aTextField", "")))
{
$valMessage[ ] = "The text field should not be empty";
}
if($this->data("aNumberField", "") != 12)
{
$valMessage[ ] = "Number field should be 12";
}
(etc etc etc etc)[br][br]return $valMessage;[/strong][/pre]
[br][br]Each message just do $valMessage[ ] = (the message) to add it onto the message list[br][br]2. Put in an event switcher[br]Data provider: {var.empty:customValidation}[br]Events: true, false[br]click update events list[br][br]3. Drag a message and an event loader into the "false" bit[br]content: {var:customValidation}[br][br][br]Now, if there are any error messages they all get displayed correctly as a list with bulletpoints and everything. The event loader reloads the page and stops the crappy data being submitted any further. Makes sure you put it UNDER the message, or the message won't be displayed.
If you want to validate a bunch of things in PHP (serverside) and have it display helpful messages.
1. Add a PHP action under setup. For example:
[strong]Name: customValidation
[/strong][pre][strong]$valMessage = [ ];
if(empty($this->data("aTextField", "")))
{
$valMessage[ ] = "The text field should not be empty";
}
if($this->data("aNumberField", "") != 12)
{
$valMessage[ ] = "Number field should be 12";
}
(etc etc etc etc)[br][br]return $valMessage;[/strong][/pre]
[br][br]Each message just do $valMessage[ ] = (the message) to add it onto the message list[br][br]2. Put in an event switcher[br]Data provider: {var.empty:customValidation}[br]Events: true, false[br]click update events list[br][br]3. Drag a message and an event loader into the "false" bit[br]content: {var:customValidation}[br][br][br]Now, if there are any error messages they all get displayed correctly as a list with bulletpoints and everything. The event loader reloads the page and stops the crappy data being submitted any further. Makes sure you put it UNDER the message, or the message won't be displayed.
The above code prevents data from saving and event switch works perfectly , but the message only shows the text "Array"
There have been many updates since then. Try
{var.ul:customValidation}instead
This topic is locked and no more replies can be posted.