# -- $class->to_field($has_many_col); # foreign inputs
# $class->search_inputs; /
-use 5.006;
-
use strict;
use warnings;
_options_from_objects _options_from_arrays _options_from_hashes
_options_from_array _options_from_hash _to_select_or_create
);
-
-our @EXPORTOK =
- qw(
-
-
- );
-
-
-our $VERSION = '.10';
+our $VERSION = '.10';
=head1 NAME
$beer->to_field($col, $args);
Not all _to_* methods pay attention to all arguments. For example, '_to_textfield' does not look in $args->{'items'} at all.
-
+
+=over
+
=item name -- the name the element will have , this trumps the derived name.
$beer->to_field('brewery', 'readonly', {
name => 'brewery_id'
});
-
+
=item value -- the initial value the element will have, trumps derived value
$beer->to_field('brewery', 'textfield', {
constraint => {location => 'London'},
'join' => {'brewery_tablecolumn => 'beer_obj_column'},
);
-
+
=item no_hidden_constraints --
Tell AsForm not to make hidden inputs for relationship constraints. It does
this sometimes when making foreign inputs .
+=back
=head2 to_cgi
}
+=head2 unselect_element
+
+ unselect any selected elemets in a HTML::Element select list widget
+
+=cut
#
sub unselect_element {
}
return;
}
-
+
+
=head2 _field_from_column($field, $args)
Returns an input based on the column's characteristics, namely type, or nothing.
}
return $a;
-
-
}
-
-
-
-
-
-
=head2 _options_from_objects ( $objects, $args);
Private method to makes a options out of objects. It attempts to call each
my $val = $_->{$pk};
my $opt = HTML::Element->new("option", value => $val );
$opt->attr(selected => "selected") if $selected->{$val};
- my $content = $fclass and $stringify and $fclass->can($stringify) ?
+ my $content = ($fclass and $stringify and $fclass->can($stringify)) ?
$fclass->$stringify($_) :
join(' ', @$_);
$opt->push_content( $content );
my $create = $self->to_field($col, 'foreign_inputs', $args);
$create->{'__select_or_create__'} =
$self->to_field('__select_or_create__',{ name => '__select_or_create__' , value => 1 } );
-
return ($select, $create);
}
-
-
-
+
#
# checkboxes: if no data in hand (ie called as class method), replace
# with a radio button, in order to allow this field to be left
sub _to_checkbox {
my ($self, $col, $args) = @_;
my $nullable = eval {self->column_nullable($col)} || 0;
-
return $self->_to_radio($col) if !ref($self) || $nullable;
my $value = $self->$col;
my $a = HTML::Element->new("input", type=> "checkbox", name => $col);
foreach (keys %$element);
}
}
-=head2 _box($value)
+
+=head2 _box($value)
This functions computes the dimensions of a textarea based on the value
or the defaults.
=cut
our ($min_rows, $max_rows, $min_cols, $max_cols) = (2 => 50, 20 => 100);
+
sub _box
{
my $text = shift;
my $output;
# Need to be very careful here.
my $tt = Template->new;
+ unless (ref $r->{config}) {
+ warn "no config for this request\n";
+ $error .= '<br> There was a problem finding configuration for this request';
+ $r->{config} ||= {};
+ }
if ($tt->process(\$error_template,
- { err_type => $type, error => $error,
- config => { %{$r->{config}}},
- request => $r, # We have that at least
+ { err_type => $type, error => $error,
+ config => { (%{$r->{config}}) },
+ request => $r, # We have that at least
eval{$self->vars($r)} }, \$output )) {
$r->{output} = $output;
if ($tt->error) { $r->{output} = "<html><body>Even the error template