Rob Posted April 25, 2013 Share Posted April 25, 2013 I ran into a strange problem to do with checking if a field is empty and then rendering content or not. Having poked around a bit it seems to me that the Markdown Extra formatter is actually outputting a string with a single space in it when I have no content in that field in the CMS. This meant that, in the context of my TWIG-powered templates, when I was checking for a non-empty field, it was returning false and still rendering something. Can anyone confirm this for me? I have a textarea field with a single Markdown Extra formatter. When I enter nothing and save, then I var_dump() the field in my PHP code, I get a 1-character empty string. Thanks in advance! Link to comment Share on other sites More sharing options...
WillyC Posted April 25, 2013 Share Posted April 25, 2013 pargraph stripper.textformattster u set run after.markdown Link to comment Share on other sites More sharing options...
Soma Posted April 25, 2013 Share Posted April 25, 2013 Has come up a cuple times http://processwire.com/talk/topic/546-how-to-detect-an-empty-field/ Link to comment Share on other sites More sharing options...
Rob Posted April 25, 2013 Author Share Posted April 25, 2013 Thanks for the pointers - is the suggestion therefore that there is a bug but it's just one I have to work around? Link to comment Share on other sites More sharing options...
Rob Posted April 25, 2013 Author Share Posted April 25, 2013 I tried adding paragraph stripper formatter after markdown, and before, it made no difference at all. There is an empty space at the end of whatever is generated, with or without any extra fomatters. I guess I'll just have to work around it. 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