RELEVANT
attributeDispite the fact that XForms can not really be used on the web (in general) it is fun to play with it from time to time to see what kind of solutions it has to offer to problems that are commonly solved with scripting. One of those features is the RELEVANT
attribute which can be used to make a form control to depend on another form control its value.
I made a sample for myself to play with it in Mozilla but I couldn’t get it to work. At least, the form control with the attribute specified did not look disabled at all and I could enter all kinds of data in it without the requirements specified being met. It might be that my plugin version is rather old, but I doubt it.
Anyway, you can test RELEVANT
for yourself.
Ah, the reason it did not work in Mozilla as expected was that it needed some kind of default styling:
@namespace xf url("http://www.w3.org/2002/xforms"); /* Should be pseudoelement |::value| instead of |input|, * and pseudoclass |:invalid| instead of |[invalid]| */ xf|*[invalid] input { background-color: red; } xf|*[required] input { background-color: green; } /* Should be pseudoclass, |:disabled| instead of |[disabled]| */ xf|*[disabled] { display: none; }
Thanks to Aaron Reed for pointing this out by e-mail.
We have no default styling for non-relevant controls in Mozilla, if you style XForms elements with a disabled
attribute to f.x. display:none
, you'll get your expected result. Or use the readonly
attribute instead -- still no styling, but it disables the control.
And where's the head
element btw?
Allan, I think there should be some form of default styling. Mozilla should not require style sheets for XForms to work as expected.
I can only agree, but we've just ignored it for now.