# Copyright (c) 1999-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: Text.pm,v 2.11 2008/08/16 04:47:17 nagler Exp $ package Bivio::UI::HTML::Widget::Text; use strict; use Bivio::Base 'HTMLWidget.InputTextBase'; our($VERSION) = sprintf('%d.%02d', q$Revision: 2.11 $ =~ /\d+/g); sub initialize { my($self) = @_; $self->unsafe_initialize_attr('format'); return shift->SUPER::initialize(@_); } sub internal_attributes { return [@{shift->SUPER::internal_attributes(@_)}, 'format']; } sub internal_input_base_render_attrs { my($self, $form, $field, $source, $buffer) = @_; shift->SUPER::internal_input_base_render_attrs(@_); my($v); if (!$form->get_field_error($field) and my $f = $self->unsafe_resolve_attr('format', $source) ) { $f = Bivio::UI::HTML::Format->get_instance($f) unless ref($f); $v = $f->get_widget_value($form->get($field)); $v = Bivio::HTML->escape($v) unless $f->result_is_html; } $v = $form->get_field_as_html($field) unless defined($v); $$buffer .= qq{ value="$v"}; return; } 1;