^empty vs ^notempty

(Lewis) #1


Anyone got any ideas why the bit in blue works but the bit in yellow doesn’t?

(Aleks Bochniak) #2

When you say it doesn’t work, what happens? it prints nothing? try the modifier charcount to test what the size is

(Lewis) #3

Hi @aleks. Thanks for the reply!

When there’s an error message from the form field, it appears as the substitution for the yellow bit (weird!) and when there’s no error message, nothing appear as the substitution for the yellow bit at all.

The blue bit is fine - the error message appears and disappears as appropriate.

Good shout on the use of ^charcount - that was my next thought. Either that or go the whole hog and use %begin_ keywords. I’ve use them before elsewhere and, if I recall, they worked at least. It’s just odd how ^notempty does what you’d expect but ^empty behaves oddly :thinking:

(Aleks Bochniak) #4


(Iain Simmons) #5

Hi @lewis,

^empty will show the value of the keyword when it is NOT empty, and the text you specify when it is.

You might have better luck with %question_error_455782_q1^eq::form-message_show:% and %question_error_455782_q1^eq:::form-error_show% (note the placement of the colons, since this is effectively looking for a blank value).


(Lewis) #6

Yep, definitely will @aleks if ^charcount doesn’t work on its own.

Keep ya’ll posted :blush:

(Lewis) #7

Ok, thanks @isimmons!

Just like @aleks’ suggestion above, I was going to try different things and ^eq was certainly a contender too, although I must admit, I was of the belief that it only works with numeric values? I’ll give it a go too - something is bound to work eventually.

As I say, just unusual how ^notempty works quite happily and as expected but ^empty doesn’t - to the extreme there I get the error message itself instead of the class name! :thinking:

I’m going to give your suggestions and @aleks’ ones a go too and let ya’ll know what ends up working.

(Lewis) #8

For those that are interested, I substituted ^empty for %begin_ (see below - yellow bit) and it works.

I tried ^charcount on its own and that didn’t work, also ^charcount^eq:0 … etc didn’t work the way you’d expect, neither did ^charcount^gt:0

The %begin_ approach is obviously more longwinded - %question_error_XXXXXX_qXX^empty: … is so much neater but there we have it.

As I said, I’ve used %begin before, elsewhere on another site and it worked but ^empty just looked nicer. Shame it doesn’t respond how you’d expect.