Sure, that's easy.

<ae:parameter name="error_class_map">
<ae:parameter name="ancestor::${htmlnsPrefix}div[contains(@class, 'group')] | self::${htmlnsPrefix}*">error</ae:parameter>
</ae:parameter>

This query retrieves a union of the elements themselves (self::*) and the encapuslating div that has "group" in the "class" attribute (you could do @class='group', but that wouldn't work for class="group hidden" or so) and applies the class "error" to them.

However, that will cause the parent to have two "error" classes. If you find that annoying, do this:

<ae:parameter name="error_class_map">
        <ae:parameter name="self::${htmlnsPrefix}label">error</ae:parameter>
<ae:parameter name="ancestor::${htmlnsPrefix}div[contains(@class, 'group')] | self::${htmlnsPrefix}*">error</ae:parameter>
</ae:parameter>

FPF stops on first match, so when it deals with labels, it won't also mark the enclosing div, while for all other elements, it will.

- David

P.S: see, this is why XPath is superior to CSS for anything other than styling HTML pages...

P.P.S: the default setting FPF uses is:
<ae:parameter name="error_class_map">
        <ae:parameter name="self::${htmlnsPrefix}*">error</ae:parameter>
</ae:parameter>


On 15.10.2009, at 17:26, Michal Charemza wrote:

Hi,

A few times now I have wanted to added an error class to the parent of
the input / label elements on error, e.g. from

<div class="group">
  <label for="test">Test</label>
  <input type="text" id="test" name="test" />
</div>

to:

<div class="group error">
  <label for="test" class="error">Test</label>
  <div class="errors"><p class="error">Error!</p></div>
  <input class="error" type="text" id="test" name="test" />
</div>

How would I go about doing this?

Michal.

_______________________________________________
users mailing list
[email protected]
http://lists.agavi.org/mailman/listinfo/users


Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________
users mailing list
[email protected]
http://lists.agavi.org/mailman/listinfo/users

Reply via email to