Forums

Calling error short code from PHP

NickOg 12 Apr, 2019
I have been able to use this succesfully in the past (from a validation procedure)
  if (!isset($thisData['conveners'])) {
$isDataValid = 'NO';
?>
{error:You must include at least one convener}
<?php
} else {
Now the text appears on return to my form but this is the result


The 'just testing' message comes from a custom code control.


Ways round it but it was working.

Nick
healyhatman 12 Apr, 2019
if(empty($this->data("fieldname"))

And this is in a Custom Code block, right?
NickOg 12 Apr, 2019
isset seems to detect the error but empty makes more sense.

function is called from a php logic block so:


Nick
healyhatman 12 Apr, 2019
Yes but the block you're having trouble with, is it in a PHP block or a Custom Code block?

Also you can just do it like this
JFactory::getApplication()->enqueueMessage("Message", "type");

https://docs.joomla.org/Display_error_messages_and_notices
NickOg 12 Apr, 2019
a php block. I will swap to a custom code block shortly and try that first. I can use the PHP approach if not.

Nick
NickOg 12 Apr, 2019
Answer
Using a custom code block partially fixed it.
<?php
$this->set('validateCourseDataValues',validateCourseDataValuesV6($this->data,$this->get('read_data1.mdlTermInfo')));
?>
The messages appeared correctly but while validateCourseDataValues is set within the php code {var:validateCourseDataValues} is not available outside that custom code. I could not use the return values in a event switch.

The enqueueMessage method works though the message appears in the PHP form rather than the chronoforms orm.

Nick

.
This topic is locked and no more replies can be posted.