# Copyright (c) 2008 bivio Software, Inc. All Rights Reserved. # # Visit http://www.bivio.biz for more info. # # This library is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as # published by the Free Software Foundation; either version 2.1 of the # License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; If not, you may get a copy from: # http://www.opensource.org/licenses/lgpl-license.html # # $Id: InputTextBase.pm,v 1.2 2008/03/27 19:10:35 nagler Exp $ package Bivio::UI::HTML::Widget::InputTextBase; use strict; use Bivio::Base 'HTMLWidget.InputBase'; our($VERSION) = sprintf('%d.%02d', q$Revision: 1.2 $ =~ /\d+/g); sub internal_attributes { return [@{shift->SUPER::internal_attributes(@_)}, qw(size max_width)]; } sub initialize { my($self) = @_; $self->initialize_attr('size'); $self->unsafe_initialize_attr('max_width'); return shift->SUPER::initialize(@_); } sub internal_input_base_render_attrs { my($self, $form, $field, $source, $buffer) = @_; shift->SUPER::internal_input_base_render_attrs(@_); my($t) = $form->get_field_type($field); my($req) = $source->get_request; my($size) = $self->render_simple_attr('size', $source); my($width) = $self->render_simple_attr('max_width', $source) || $t->get_width; $size += 2 if $size == $width; $$buffer .= qq{ type="@{[$t->is_password ? 'password' : 'text']}"} . qq{ size="$size" maxlength="$width"}; return; } 1;