[html-formfu] Wrapping input inside <label>...</label> for Checkboxgroup

Carl Franks fireartist at gmail.com
Wed Mar 12 16:28:05 GMT 2008


On 12/03/2008, kewei xiao <kewei.xiao at nald.ca> wrote:
> Hi guys
>
>     I am trying to wrap input box inside <label>...</label> for my
>  customized checkboxgroup, like this:
>
>    <label>
>        <input....../>
>    </label>

Do you strictly need this?
As long as the checkbox has an ID, the label will be given a for="id"
attribute so that the browser correctly associates the label with the
checkbox.

<input name="foo" type="checkbox" value="1" id="foo" />
<label for="foo">One</label>

It should also be possible to use CSS to make the checkbox render to
the right-hand side of the label, if that's what you want.

That said, If you want to change the generated markup, you'll have to
configure that element to use the TT template files, rather than using
the internal string method.

Copy the 'checkboxgroup_tag' file, edit it as necessary, then
configure the element to use your new file:

    type: Checkboxgroup
    render_method: 'tt'
    field_filename: 'new-filename'

You'll also have to make sure that the directory containing the
customized file is listed in
    $form->tt_args->{INCLUDE_PATH} = []


Carl



More information about the HTML-FormFu mailing list