0

The extension library offers means to structure your forms by Form Tables, where you can put Form Layout Columns and Form Layout Rows.

The Form Layout Rows have a property called "for" (the "For Indentifier") - here is the OnHover-text:

"Holds the ID of the control used to edit the data. That control should be contained within this Form Layout Row control."

So, I could enter the id of e.g. an Edit Box control I put into this form row (which translates to the code ' for="inputText1" '). But what exactly is this needed for? Where or for what can this information be used?

I found no different behaviour or limited functionality when sparing this information - at least, not how we use it atm. I found nothing in the web regarding this question; hope anyone can shed some light.

DonMaro
  • 82
  • 9
  • This is not specific to XPages. See http://stackoverflow.com/questions/18432376/what-does-for-attribute-do-in-label-tags – Paul Stephen Withers Dec 01 '15 at 13:54
  • 1
    It's helpful for accessibility purposes, allowing screen readers to know what the label is referring to – Brian Gleeson - IBM Dec 01 '15 at 16:06
  • 1
    @PaulStephenWithers, thanks for the link - I was aware of this function in good ol' HTML. Out of curiosity, I just tried clicking the formRow label in my applications, and it does work identically, setting the cursor into the related field. **Awesome, never noticed before!** But as I did not declare the 'for' attribute, this behavior seems to come from the simple '' declaration and the nice OneUI... – DonMaro Jan 14 '16 at 09:29

2 Answers2

2

It's useful if your form row contains multiple controls, preventing the form row's code from determining its "for" target automatically. In that situation, you can provide the server-side ID of the "real" target control in the row to keep the label behavior working properly.

Jesse Gallagher
  • 4,461
  • 13
  • 11
  • Dear Jesse, alright, seems to be reasonable when it comes to multiple controls in one formRow; we also have this every once in a while... but still, what does this "link" between label and control **do**? How is the target control exactly affected? What is the "label behavior"? I tried and still don't notice a difference between declaring the 'for' attribute and sparing it. – DonMaro Jan 14 '16 at 09:21
  • 1
    At a base level, it's the same as the HTML label/for/control pairing: if you click on the label text, it'll focus on the control, and it presumably improves accessibility and the like. At the XPages level, I suspect it also lets the form row appear differently when the field is required. – Jesse Gallagher Jan 14 '16 at 15:00
2

It's also mandatory to set this attribute if you want to use the built-in OneUI or Bootstrap themes to have the label formatted correctly. For example the text will be bold only if you set the for attribute (Bootstrap acts like this)

Oliver Busse
  • 3,375
  • 1
  • 16
  • 26
  • Dear Oliver, we're using OneUI and it seems to format labels still as bold, even when I spare the 'for' attribute - did not find any custom css we might have added for that... so maybe it just evaluates the 'xe:this.label' for correct formatting. But I see get point, thanks. – DonMaro Jan 14 '16 at 09:16