Subject: | HTML attributes not passed to render functions in HTML::FormHandler::Render::Simple |
Although the manual for HTML::FormHandler::Field says you can set
various HTML attributes on a field, they are not rendered in the output
HTML by HTML::FormHandler::Render::Simple. These are: readonly,
disabled, style, order, cdd_class and javascript.
Below is a patch for HTML::FormHandler::Render::Simple that enhances
each render subroutine to call a private method _add_html_attributes()
just before the NTML tag is closed.
231,233c231
< $output .= ' value="' . $field->fif . '"';
< $output .= $self->_add_html_attributes( $field );
< $output .= ' />';
---
Show quoted text
> $output .= ' value="' . $field->fif . '" />';
244,246c242
< $output .= ' value="' . $field->fif . '"';
< $output .= $self->_add_html_attributes( $field );
< $output .= ' />';
---
Show quoted text> $output .= ' value="' . $field->fif . '" />';
255,257c251
< $output .= ' value="' . $field->fif . '"';
< $output .= $self->_add_html_attributes( $field );
< $output .= ' />';
---
Show quoted text> $output .= ' value="' . $field->fif . '" />';
268d261
< $output .= $self->_add_html_attributes( $field );
307d299
< $output .= $self->_add_html_attributes( $field );
321d312
< $output .= $self->_add_html_attributes( $field );
338c329
< qq(<textarea name="$name" id="$id" ) . qq(rows="$rows"
cols="$cols") . $self->_add_html_attributes( $field ) .
qq(>$fif</textarea >);
---
Show quoted text> qq(<textarea name="$name" id="$id" ) . qq(rows="$rows"
cols="$cols">$fif</textarea>);
364,366c355
< $output .= ' value="' . $field->value . '"';
< $output .= $self->_add_html_attributes( $field );
< $output .= ' />';
---
Show quoted text> $output .= ' value="' . $field->value . '" />';
376,394c365
< $output .= ' value="' . $field->value . '"';
< $output .= $self->_add_html_attributes( $field );
< $output .= ' />';
< return $output;
< }
<
< sub _add_html_attributes {
< my ( $self, $field ) = @_;
<
< my $output = q{};
< for my $attr (qw{readonly disabled style order}) {
< $output .= ($field->$attr ? qq{ $attr="} . $field->$attr . '"'
: '');
< }
<
< # Special case for css_class
< $output .= ($field->css_class ? ' class="' . $field->css_class .
'"' : '');
<
< # Special case for javascript
< $output .= ($field->javascript ? ' ' . $field->javascript : '');
---
Show quoted text> $output .= ' value="' . $field->value . '" />';