Forums

PHP code to load in "frontend"?

trunky 14 Aug, 2012
Hi,

I have an entry form and want to show how many places are available still. These data are stored in a simple textfile and the custom code block in the On Submit event seems to work fine. But I have a problem in displaying it in the form itself. I've tried a custom code element with php but this doesn't work. And a code block in the On Load event would work but how I populate the form with the data then?

Any help is appreciated

trunky
GreyHead 15 Aug, 2012
Hi trunky,

You don't say how you want to display this data in your form?

You can use a Custom Code element to add a value to the $form->data array and then use that to set the value of an input; or echo it out directly from a Custom Element element.

Bob
trunky 15 Aug, 2012
Hi Bob,

I simply try to read a number from a textfile (and decrease it when someone has filled the form). The writing back in the custom code block in On Submit works, but if I put php code inside the custom element it always comes out with { } ???

trunky
GreyHead 15 Aug, 2012
Hi trunky,

What PHP are you putting inside the Custom Element element?

Bob
trunky 17 Aug, 2012
Hello Bob,

I am sorry, was my bad! It is working as expected, thank you. I had a wrong txt file so the output was weird.

topic closed

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