# 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: FormButton.pm,v 2.10 2010/02/01 21:00:14 dobbs Exp $ package Bivio::UI::HTML::Widget::FormButton; use strict; use Bivio::Base 'HTMLWidget.ControlBase'; # C a form specific submit button. # # Font is always C. # # # # attributes : string [] # # Attributes to be applied to the button. C # uses this to set "onclick=reset()". # # field : string (required) # # Name of the form field. # # form_model : array_ref (required, inherited, get_request) # # Which form are we dealing with. # # label : string [Model.field] # # String label to use. # # label : array_ref # # If specified, the button text will be determined by calling # L on the rendering source. our($VERSION) = sprintf('%d.%02d', q$Revision: 2.10 $ =~ /\d+/g); my($_VS) = 'Bivio::UI::HTML::ViewShortcuts'; my($_F) = b_use('FacadeComponent.Font'); sub NEW_ARGS { return [qw(field ?class)]; } sub control_on_render { my($self, $source, $buffer) = @_; my($p, $s) = $_F->format_html('form_submit', $source->req); my($a) = $self->render_simple_attr('attributes', $source); $a = " $a" if $a && $a =~ /^\S/; $$buffer .= $p . 'SUPER::control_on_render($source, $buffer); $$buffer .= " />$s"; return; } sub initialize { my($self) = shift; $self->put_unless_exists(label => sub { $_VS->vs_text( $self->ancestral_get('form_class')->simple_package_name, $self->get('field'), ); })->map_invoke( unsafe_initialize_attr => [qw(label attributes)], ); return $self->SUPER::initialize(@_); } 1;