Using formatters

When using the Set value in the server side I am trying to use a formatter.

Created a file in dmxConnectLib/lib/core:

I just can’t seem to implement the formatted all I ever get returned is a null.

Added a test function just test and only ever get a null, not way to debug so any help is needed:

function formatter_rethel() {
       return 'hello';
 }

Also tried it as:

function formatter_rethel($val) {
$data = ‘hello’;
}

Screenshot 2020-10-19 at 20.29.22

Tried everything I can think of all I get back in null

Screenshot 2020-10-19 at 20.33.07

Also my server side

Screenshot 2020-10-19 at 20.40.52

1 Like

You should see the formatter as a function mutating an existing value.
So you always append it a a field like:

{{somevalue.myformatter()}}

it will execute the formatter and give the input field as parameter, so you have to manipulate it and return a new value.

See also about making custom formatters:

When I add to the formatters.php file it works great. The minute I create an custom.php file and put the function in their i get the following:

code: 0
file: “/var/www/html/dmxConnectLib/lib/core/Parser.php”
line: 404
message: “Formatter base64toimage does not exist.”
trace: “#0 /var/www/html/dmxConnectLib/lib/core/Parser.php(355): lib\core\Parser->objectMember(Object(Closure))↵#1 /var/www/html/dmxConnectLib/lib/core/Parser.php(297): lib\core\Parser->primary()↵#2 /var/www/html/dmxConnectLib/lib/core/Parser.php(274): lib\core\Parser->group()↵#3 /var/www/html/dmxConnectLib/lib/core/Parser.php(254): lib\core\Parser->unary()↵#4 /var/www/html/dmxConnectLib/lib/core/Parser.php(244): lib\core\Parser->multiplicative()↵#5 /var/www/html/dmxConnectLib/lib/core/Parser.php(234): lib\core\Parser->addictive()↵#6 /var/www/html/dmxConnectLib/lib/core/Parser.php(224): lib\core\Parser->bitwiseShift()↵#7 /var/www/html/dmxConnectLib/lib/core/Parser.php(214): lib\core\Parser->relational()↵#8 /var/www/html/dmxConnectLib/lib/core/Parser.php(204): lib\core\Parser->equality()↵#9 /var/www/html/dmxConnectLib/lib/core/Parser.php(194): lib\core\Parser->bitwiseAnd()↵#10 /var/www/html/dmxConnectLib/lib/core/Parser.php(184): lib\core\Parser->bitwiseXor()↵#11 /var/www/html/dmxConnectLib/lib/core/Parser.php(174): lib\core\Parser->bitwiseOr()↵#12 /var/www/html/dmxConnectLib/lib/core/Parser.php(162): lib\core\Parser->logicalAnd()↵#13 /var/www/html/dmxConnectLib/lib/core/Parser.php(146): lib\core\Parser->logicalOr()↵#14 /var/www/html/dmxConnectLib/lib/core/Parser.php(142): lib\core\Parser->conditional()↵#15 /var/www/html/dmxConnectLib/lib/core/Parser.php(87): lib\core\Parser->expression()↵#16 /var/www/html/dmxConnectLib/lib/App.php(222): lib\core\Parser->parse(‘a.base64toimage…’, NULL)↵#17 /var/www/html/dmxConnectLib/lib/App.php(207): lib\App->parseObject(’{{a.base64toima…’, NULL)↵#18 /var/www/html/dmxConnectLib/modules/core.php(99): lib\App->parseObject(Object(stdClass))↵#19 /var/www/html/dmxConnectLib/lib/App.php(174): modules\core->setvalue(Object(stdClass), ‘newavatar’)↵#20 /var/www/html/dmxConnectLib/lib/App.php(108): lib\App->execSteps(Object(stdClass))↵#21 /var/www/html/dmxConnectLib/modules/core.php(90): lib\App->exec(Object(stdClass), true)↵#22 /var/www/html/dmxConnectLib/lib/App.php(174): modules\core->condition(Object(stdClass), ‘’)↵#23 /var/www/html/dmxConnectLib/lib/App.php(138): lib\App->execSteps(Object(stdClass))↵#24 /var/www/html/dmxConnectLib/lib/App.php(108): lib\App->execSteps(Array)↵#25 /var/www/html/dmxConnectLib/lib/App.php(73): lib\App->exec(Object(stdClass))↵#26 /var/www/html/dmxConnect/api/Security/updateUser.php(8): lib\App->define(Object(stdClass))↵#27 {main}”

Clicked the upload arrow a few times. Refeshed etc. stopped and restarted services.

Any ideas?

custom.php file

Where did you save the custom.php?

Posted it in the following:

Saved it mean

Formatters needs to be placed in dmxConnectLib/lib/formatters.

Of course! I knew that… was just checking to see if you are awake.

Thanks it is all working now.