Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the HTML-FormHandler CPAN distribution.

Report information
The Basics
Id: 52123
Status: resolved
Priority: 0/
Queue: HTML-FormHandler

People
Owner: Nobody in particular
Requestors: perl [...] tanoti.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.01
Fixed in: (no value)



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 . '" />';
The patch was applied to HTML::FormHandler::Render::Simple and shipped in the last release (0.29), with the exception of the way that css_class was used. We were already using that in a different way.