gshank/html-formhandler

documentation is incorrect about 'element_attr'

Closed this issue · 2 comments

The docs say:

('element_wrapper' is for an inner div around the input element, not
including the label. Used for Bootstrap3 rendering, but also available
in the Simple wrapper.)

But actually, any styling added when $type eq 'element' will end up on the <input> attribute itself, not the wrapping <div>:

sub field_list { [
    {
        name    => 'publisher_id',
        type    => 'Text',
        label   => 'Publisher',
        element_attr => { disabled => 1 },
    },
] }

sub html_attributes {
    my ( $self, $field, $type, $attr ) = @_;

    $attr->{style} = join('; ', ($attr->{style} // ()), 'font-style: italic')
        if $type eq 'element' and $field->name eq 'publisher_id' and $field->value eq 'all';

    return $attr;
}

..renders as:

<div class="form-group">
<label class="col-lg-2 control-label" for="publisher_id">Publisher</label>
<div class="col-lg-5">
<input name="publisher_id" id="publisher_id" value="all" class="form-control" disabled="1" style="font-style: italic" type="text"></div>
</div>

Yes, there’s a difference between ‘element’ (+ element_class &
element_attributes) and ‘element_wrapper’ (+ element_wrapper_class &
element_wrapper_attributes).

Gerda

On Thu, Oct 20, 2016 at 7:46 PM, Karen Etheridge notifications@github.com
wrote:

The docs say:

('element_wrapper' is for an inner div around the input element, not
including the label. Used for Bootstrap3 rendering, but also available
in the Simple wrapper.)

But actually, any styling added when $type eq 'element' will end up on
the attribute itself, not the wrapping

:

sub field_list { [
{
name => 'publisher_id',
type => 'Text',
label => 'Publisher',
element_attr => { disabled => 1 },
},
] }

sub html_attributes {
my ( $self, $field, $type, $attr ) = @_;

$attr->{style} = join('; ', ($attr->{style} // ()), 'font-style: italic')
    if $type eq 'element' and $field->name eq 'publisher_id';

return $attr;

}

..renders as:

Publisher


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#128, or mute the
thread
https://github.com/notifications/unsubscribe-auth/AACUowFyT7FEgbAKCGB8D7-iiIK7wdsxks5q1_1bgaJpZM4KcuLN
.

aha, I didn't realize there was both an 'element' and an 'element_wrapper'. thanks, closing!