OPNsense Forum

English Forums => Development and Code Review => Topic started by: NOYB on January 12, 2018, 09:25:28 am

Title: "for" attribute usage in form_input_tr.volt
Post by: NOYB on January 12, 2018, 09:25:28 am
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/
Code: [Select]
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>
Title: Re: "for" attribute usage in form_input_tr.volt
Post by: franco on January 12, 2018, 09:52:45 am
They are used in e.g. Services: Web Proxy pages to generate the form.


Cheers,
Franco
Title: Re: "for" attribute usage in form_input_tr.volt
Post by: NOYB on January 12, 2018, 10:49:25 am
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.
Title: Re: "for" attribute usage in form_input_tr.volt
Post by: franco on January 12, 2018, 11:22:01 am
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
Title: Re: "for" attribute usage in form_input_tr.volt
Post by: NOYB on January 12, 2018, 11:35:39 am
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
Title: Re: "for" attribute usage in form_input_tr.volt
Post by: franco on January 12, 2018, 11:51:24 am
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
Title: Re: "for" attribute usage in form_input_tr.volt
Post by: franco on January 12, 2018, 12:03:16 pm
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
Title: Re: "for" attribute usage in form_input_tr.volt
Post by: fabian on January 12, 2018, 08:07:47 pm
@franco - the only thing I am aware of to be after the input elements are the validation messages.
Title: Re: "for" attribute usage in form_input_tr.volt
Post by: franco on January 13, 2018, 11:24:03 am
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
Title: Re: "for" attribute usage in form_input_tr.volt
Post by: NOYB on January 20, 2018, 09:57:05 am
Over here instead
https://forum.opnsense.org/index.php?topic=6940.0