"for" attribute usage in form_input_tr.volt

Started by NOYB, January 12, 2018, 09:25:28 AM

Previous topic - Next topic
January 12, 2018, 09:25:28 AM Last Edit: January 12, 2018, 09:47:27 AM by NOYB
Having trouble understanding the "for" attribute in the <tr> (line 45) and <span> (line 81) elements here.
Could someone please shed some light on how, when, and where these are made use of?
Thanks.

form_input_tr.volt
/usr/local/opnsense/mvc/app/views/layout_partials/

45: <tr for="{{ id }}" {% if advanced|default(false)=='true' %} data-advanced="true"{% endif %}>
. . .
        <input id="{{ id }}" ... >
. . .
80:     <td>
81:         <span class="help-block" for="{{ id }}" ></span>
82:     </td>
83: </tr>


They are used in e.g. Services: Web Proxy pages to generate the form.


Cheers,
Franco

I know the elements (<tr> and <span>) are used in generating the form.  But what is the roll of the "for" attribute on the <tr> and <span> element there?
Thanks.

It's strange indeed. It should ideally mark the label "Enable proxy" and link it to the checkbox. I'd say tr-for should be dropped, and the td around span should be zapped in favour of a colspan="2" for the former column?


Cheers,
Franco

Thanks that's what I was looking for.

Seems reasonable to drop the tr-for.  Don't see how it would do anything there.

Seems reasonable to put the help-block beneath the input field.

So far I've not seen anything that actually uses the help-block to display anything there.  Is there anything that uses it or that may in the future?

Thanks

The help is displayed underneath like done in the static pages. There seems to be no need for the third column. But I'll ask for another opinion in a second.


Cheers,
Franco

Ad said we need to be a bit careful as the MVC is used by others / external applications and there may also be code that depends on this in opnsense_ui.js still.


Cheers,
Franco

@franco - the only thing I am aware of to be after the input elements are the validation messages.

True. Ideally, the whole thing needs a rework later this year. I also want a couple of accessibility improvements here. For now, the third column in the forms seems like wasted screen real estate, but it is what it is.


Cheers,
Franco