helmut2509 Posted March 1, 2015 Posted March 1, 2015 I have a custom script in which I want to validate the contents of input fields. however it seems, that $sanitizer and $input are not available there, I get this error message: "Trying to get property of non-object". So how can I make those variables available in my custom script?
LostKobrakai Posted March 1, 2015 Posted March 1, 2015 See the last post here: https://processwire.com/talk/topic/5857-using-pages-in-custom-function/#entry88975 1
helmut2509 Posted March 4, 2015 Author Posted March 4, 2015 See the last post here: https://processwire.com/talk/topic/5857-using-pages-in-custom-function/#entry88975 I tried this: $sanitizer = wire('sanitizer'); $input = wire('input'); But at using $input I get the error message: Trying to get property of non-object ...and at using $sanitizer I get : ..Call to a member function text() on a non-object
adrian Posted March 4, 2015 Posted March 4, 2015 "Custom Script" - does that mean your code is not in a PW template or module file? Have you bootstrapped in PW so you can access its API? https://processwire.com/api/include/ 2
helmut2509 Posted March 4, 2015 Author Posted March 4, 2015 Can you post your code? in the meantime I found out: $sanitizedInput = wire('sanitizer')->text(wire('input')->post->$fld); ...works, but $input = wire('input'); $sanitizer = wire('sanitizer'); ....... $sanitizer->text($input->post->name); ...does not work
diogo Posted March 5, 2015 Posted March 5, 2015 Again, we need to know the context of the code. Is that second code inside a function and the variables set outside of it? In alternative, you can study a bit http://php.net/manual/en/language.variables.scope.php 1
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