Jump to content

[Solved] FormTemplateProcessor - Undefined variable: page


Fran
 Share

Recommended Posts

I'm trying to use this code:

$this->set('successMessage', '<h2 class="enviado-ok">' . wire('pages')->get("/$page->name/")->mensaje_form_enviado .'</h2>');

inside the init function of FormTemplateProcessor.module and is giving me this error:

Notice: Undefined variable: page in /home/pruebase/public_html/site/modules/FormTemplateProcessor/FormTemplateProcessor.module on line 92

Notice: Trying to get property of non-object in /home/pruebase/public_html/site/modules/FormTemplateProcessor/FormTemplateProcessor.module on line 92

This is probably because I'm not really good at php and I guess I can't use the $page variable inside the function right?

Does anyone know how could I make this work? Thanks very much.

Link to comment
Share on other sites

Yes, that's true that you can't use $page inside a function, but the other thing here is that you already have wire('page') - there is no need to get the page from pages again, so this should be fine:

$this->set('successMessage', '<h2 class="enviado-ok">' . wire('page')->mensaje_form_enviado .'</h2>');

 

 

 

  • Like 3
Link to comment
Share on other sites

On 31/12/2016 at 6:54 PM, adrian said:

Yes, that's true that you can't use $page inside a function, but the other thing here is that you already have wire('page') - there is no need to get the page from pages again, so this should be fine:


$this->set('successMessage', '<h2 class="enviado-ok">' . wire('page')->mensaje_form_enviado .'</h2>');

 

 

 

You made my day Adrian !!! Working perfectly !!! Thanks very much.

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...