Fran Posted December 31, 2016 Posted December 31, 2016 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.
adrian Posted December 31, 2016 Posted December 31, 2016 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>'); 3
Fran Posted January 2, 2017 Author Posted January 2, 2017 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. 2
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now