Matthias Posted October 24, 2016 Share Posted October 24, 2016 I have a strange one. inside my module class i want to check the user input, but it does not work like expected. Trying around since hours … what am i doing wrong. Any idea? I have a form, method=post, posting a simple text input "input_name". <?php public function ready() { echo $this->input->post->input_name; // echoes the name if (empty($this->input->post->input_name)) { echo 'no name'; // echoes "no name", too } $foo = $this->input->post->input_name; if (empty($foo)) { echo 'no name'; // echoes nothing, works. } } ?> The "empty" term seems not to work. Im going crazy with this (or $this …)! Is it something about namespaces? PHP7? Any ideas? Thanks a lot! Link to comment Share on other sites More sharing options...
Zeka Posted October 24, 2016 Share Posted October 24, 2016 Hi @Matthi if($input->post->name) { ... } Did you try this? And maybe this link will be useful https://processwire.com/blog/posts/processwire-3.0.14-updates-file-compiler-fields-and-more/#best-practices-with-fields-and-values Link to comment Share on other sites More sharing options...
Matthias Posted October 24, 2016 Author Share Posted October 24, 2016 Hi Zeka, thanks a lot for the links. I switched in my MAMP between PHP 5.6 and 7 and if(empty($input->post->name)) { ... } works only in PHP 5.6 not in PHP 7. For whatever reasons, couldn’t find anything about this in the PHP Docs. Yes, I'll change to the even simpler if($input->post->name) { ... } And say byebye to "empty" ;-) Link to comment Share on other sites More sharing options...
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