# Copyright (c) 2002 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: Hidden.pm,v 2.2 2006/10/16 21:08:05 moeller Exp $ package Bivio::UI::HTML::Widget::Hidden; use strict; $Bivio::UI::HTML::Widget::Hidden::VERSION = sprintf('%d.%02d', q$Revision: 2.2 $ =~ /\d+/g); $_ = $Bivio::UI::HTML::Widget::Hidden::VERSION; =head1 NAME Bivio::UI::HTML::Widget::Hidden - hidden form field =head1 RELEASE SCOPE bOP =head1 SYNOPSIS use Bivio::UI::HTML::Widget::Hidden; =cut =head1 EXTENDS L =cut use Bivio::UI::Widget; @Bivio::UI::HTML::Widget::Hidden::ISA = ('Bivio::UI::Widget'); =head1 DESCRIPTION C draws a C tag with attribute C. =head1 ATTRIBUTES =over 4 =item field : string (required) Name of the form field. =item form_model : array_ref (required, inherited, get_request) Which form are we dealing with. =back =cut #=IMPORTS #=VARIABLES my($_IDI) = __PACKAGE__->instance_data_index; =head1 FACTORIES =cut =for html =head2 static new(hash_ref attributes) : Bivio::UI::HTML::Widget::Hidden Creates a Hidden widget. =cut sub new { my($proto) = shift; my($self) = $proto->SUPER::new(@_); $self->[$_IDI] = {}; return $self; } =head1 METHODS =cut =for html =head2 initialize() Initializes static information. In this case, prefix and suffix field values. =cut sub initialize { my($self) = @_; my($fields) = $self->[$_IDI]; return if $fields->{model}; $fields->{model} = $self->ancestral_get('form_model'); $fields->{field} = $self->get('field'); $fields->{prefix} = ' =head2 static internal_new_args(string field) : hash_ref =head2 static internal_new_args(string field, hash_ref attributes) : hash_ref Implements positional argument parsing for L. =cut sub internal_new_args { my(undef, $field, $attributes) = @_; return '"field" attribute must be defined' unless defined($field); return { field => $field, ($attributes ? %$attributes : ()), }; } =for html =head2 render(any source, Text_ref buffer) Render the hidden field. =cut sub render { my($self, $source, $buffer) = @_; my($fields) = $self->[$_IDI]; my($form) = $source->get_request->get_widget_value(@{$fields->{model}}); $$buffer .= $fields->{prefix} . $form->get_field_name_for_html($fields->{field}) . '" value="' . $form->get_field_as_html($fields->{field}) . '" />'; return; } #=PRIVATE METHODS =head1 COPYRIGHT Copyright (c) 2002 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 =head1 VERSION $Id: Hidden.pm,v 2.2 2006/10/16 21:08:05 moeller Exp $ =cut 1;