bug fixes from running t/FormGetName.t

This commit is contained in:
Colin Kuskie 2006-01-15 05:18:11 +00:00
parent 3b06849a80
commit 6a9a63c4b0
26 changed files with 70 additions and 47 deletions

View file

@ -100,17 +100,17 @@ sub toHtml {
name=>$self->get("name"),
extras=>$self->get("extras"),
value=>$asset->getId,
id=>$self->{id}
id=>$self->get("id"),
)->toHtml
.WebGUI::Form::Text->new(
name=>$self->get("name")."_display",
extras=>' readonly="1" ',
value=>$asset->get("title"),
id=>$self->{id}."_display"
id=>$self->get('id')."_display"
)->toHtml
.WebGUI::Form::Button->new(
value=>"...",
extras=>'onclick="window.open(\''.$asset->getUrl("op=formAssetTree;classLimiter=".$self->get("class").";formId=".$self->{id}).'\',\'assetPicker\',\'toolbar=no, location=no, status=no, directories=no, width=400, height=400\');"'
extras=>'onclick="window.open(\''.$asset->getUrl("op=formAssetTree;classLimiter=".$self->get("class").";formId=".$self->get('id')).'\',\'assetPicker\',\'toolbar=no, location=no, status=no, directories=no, width=400, height=400\');"'
)->toHtml;
}

View file

@ -81,7 +81,7 @@ sub toHtml {
my $value = $self->fixQuotes($self->get("value"));
my $html = '<input type="button" ';
$html .= 'name="'.$self->get("name").'" ' if ($self->get("name"));
$html .= 'id="'.$self->{id}.'" ' unless ($self->{id} eq "_formId");
$html .= 'id="'.$self->get('id').'" ' unless ($self->get('id') eq "_formId");
$html .= 'value="'.$value.'" '.$self->get("extras").' />';
return $html;
}

View file

@ -92,18 +92,18 @@ sub toHtml {
%options = $self->orderedHash();
foreach my $key (keys %options) {
my $checked = 0;
foreach my $item (@{ $self->{value} }) {
foreach my $item (@{ $self->get('value') }) {
if ($item eq $key) {
$checked = 1;
}
}
$output .= WebGUI::Form::Checkbox->new({
name=>$self->{name},
name=>$self->get('name'),
value=>$key,
extras=>$self->{extras},
extras=>$self->get('extras'),
checked=>$checked
})->toHtml;
$output .= ${$self->{options}}{$key} . $alignment;
$output .= ${$self->get('options')}{$key} . $alignment;
}
return $output;
}

View file

@ -124,7 +124,7 @@ sub toHtml {
my $self = shift;
my $value = $self->fixMacros($self->fixQuotes($self->fixSpecialCharacters($self->get("value"))));
my $checkedText = ' checked="checked"' if ($self->get("checked"));
my $idText = ' id="'.$self->{id}.'" ' if ($self->{id});
my $idText = ' id="'.$self->get('id').'" ' if ($self->get('id'));
return '<input type="checkbox" name="'.$self->get("name").'" value="'.$value.'"'.$idText.$checkedText.' '.$self->get("extras").' />';
}

View file

@ -103,7 +103,7 @@ sub toHtml {
.WebGUI::Form::Text->new(
size=>$self->session->setting->get("textBoxSize")-5,
name=>$self->get("name")."_new",
id=>$self->{id}."_new"
id=>$self->get('id')."_new"
)->toHtml;
}

View file

@ -94,7 +94,7 @@ sub toHtml {
my $self = shift;
my %types;
my $i18n = WebGUI::International->new($self->session);
foreach my $type (@{$self->get("types}")) {
foreach my $type (@{ $self->get('types') }) {
if ($type eq "text") {
$types{text} = $i18n->get(1010);
} elsif ($type eq "mixed") {

View file

@ -522,6 +522,29 @@ sub session {
}
#-------------------------------------------------------------------
=head2 set ( key, var )
Set a property of this form object.
=head3 key
The name of the property to set.
=head3 var
The value to set the property to.
=cut
sub set {
my $self = shift;
my $key = shift;
my $value = shift;
$self->{_params}{$key} = $value;
}
#-------------------------------------------------------------------
=head2 toHtml ( )

View file

@ -94,7 +94,7 @@ sub definition {
defaultValue=>$i18n->get('1075 description')
},
});
return $class->SUPER::definition($definition);
return $class->SUPER::definition($session, $definition);
}
#-------------------------------------------------------------------

View file

@ -80,7 +80,7 @@ sub definition {
defaultValue=>$i18n->get("479")
},
defaultValue=>{
defaultValue=$session->datetime->time()
defaultValue=>$session->datetime->time()
},
maxlength=>{
defaultValue=> 10
@ -150,7 +150,7 @@ sub toHtml {
$self->session->style->setLink($self->session->config->get("extrasURL").'/calendar/calendar-win2k-1.css', { rel=>"stylesheet", type=>"text/css", media=>"all" });
return $self->SUPER::toHtml. '<script type="text/javascript">
Calendar.setup({
inputField : "'.$self->{id}.'",
inputField : "'.$self->get('id').'",
ifFormat : "%Y-%m-%d",
showsTime : false,
step : 1,

View file

@ -75,7 +75,7 @@ sub definition {
defaultValue=>$i18n->get("972")
},
defaultValue=>{
defaultValue=$session->datetime->time()
defaultValue=>$session->datetime->time()
},
maxlength=>{
defaultValue=> 19
@ -128,11 +128,11 @@ sub toHtml {
value=>$value,
size=>$self->get("size"),
extras=>$self->get("extras"),
id=>$self->{id},
id=>$self->get('id'),
maxlength=>$self->get("maxlength")
)->toHtml . '<script type="text/javascript">
Calendar.setup({
inputField : "'.$self->{id}.'",
inputField : "'.$self->get('id').'",
ifFormat : "%Y-%m-%d %H:%M:%S",
showsTime : true,
step : 1,

View file

@ -129,7 +129,7 @@ sub toHtml {
my $self = shift;
my %options;
tie %options, "Tie::IxHash";
foreach my $type (@{ $self->{types} }) {
foreach my $type (@{ $self->get('types') }) {
my $class = "WebGUI::Form::".ucfirst($type);
my $cmd = "use ".$class;
eval ($cmd);
@ -139,7 +139,7 @@ sub toHtml {
}
$options{$type} = $class->getName($self->session);
}
$self->{options} = \%options;
$self->get('options') = \%options;
return $self->SUPER::toHtml();
}

View file

@ -108,10 +108,10 @@ Returns a group pull-down field. A group pull down provides a select list that p
sub toHtml {
my $self = shift;
my $where;
if ($self->get("excludeGroups")[0] ne "") {
if ($self->get('excludeGroups')->[0] ne "") {
$where = "and groupId not in (".$self->session->db->quoteAndJoin($self->get("excludeGroups")).")";
}
$self->get("options") = $self->session->db->buildHashRef("select groupId,groupName from groups where showInForms=1 $where order by groupName");
$self->set('options', $self->session->db->buildHashRef("select groupId,groupName from groups where showInForms=1 $where order by groupName"));
return $self->SUPER::toHtml();
}

View file

@ -118,11 +118,11 @@ sub toHtml {
my $self = shift;
$self->session->style->setScript($self->session->config->get("extrasURL").'/textFix.js',{ type=>'text/javascript' });
$self->get("extras") .= ' onblur="fixChars(this.form.'.$self->get("name").')" mce_editable="true" ';
return $self->SUPER::toHtml.WebGUI::Asset::RichEdit->new($self->get("richEditId"))->getRichEditor($self->{id});
return $self->SUPER::toHtml.WebGUI::Asset::RichEdit->new($self->get("richEditId"))->getRichEditor($self->get('id'));
my $i18n = WebGUI::International->new($self->session);
my $richEdit = WebGUI::Asset::RichEdit->new($self->get("richEditId"));
if (defined $richEdit) {
return $self->SUPER::toHtml.$richEdit->getRichEditor($self->{id});
return $self->SUPER::toHtml.$richEdit->getRichEditor($self->get('id'));
} else {
return $i18n->get('rich editor load error','Form_HTMLArea');
}

View file

@ -104,7 +104,7 @@ Renders an input tag of type hidden.
sub toHtmlAsHidden {
my $self = shift;
my $value = $self->fixMacros($self->fixQuotes($self->fixSpecialCharacters($self->get("value"))));
my $idText = ' id="'.$self->{id}.'" ' if ($self->{id});
my $idText = ' id="'.$self->get('id').'" ' if ($self->get('id'));
return '<input type="hidden" name="'.$self->get("name").'" value="'.$value.'" '.$self->get("extras").$idText.' />'."\n";
}

View file

@ -121,13 +121,13 @@ sub toHtml {
name=>$self->get("name")."_interval",
value=>$interval,
extras=>$self->get("extras"),
id=>$self->{id}."_interval",
id=>$self->get('id')."_interval",
)->toHtml;
$cmd = "WebGUI::Form::SelectBox";
$out .= $cmd->new(
options=>\%units,
name=>$self->get("name")."_units",
id=>$self->{id}."_units",
id=>$self->get('id')."_units",
value=>[$units]
)->toHtml;
return $out;

View file

@ -71,10 +71,10 @@ sub correctOptions {
s/\s+$//; # remove trailing spaces
$options{$_} = $_;
}
if (exists $self->{options} && ref($self->{options}) eq "HASH") {
%options = (%{$self->{options}} , %options);
if ($self->get('options') && ref($self->get('options')) eq "HASH") {
%options = (%{$self->get('options')} , %options);
}
$self->{options} = \%options;
$self->set('options', \%options);
}
@ -237,11 +237,11 @@ sub orderedHash {
my %options;
tie %options, 'Tie::IxHash';
if ($self->get("sortByValue")) {
foreach my $optionKey (sort {"\L${$self->{options}}{$a}" cmp "\L${$self->{options}}{$b}" } keys %{$self->{options}}) {
$options{$optionKey} = $self->{options}{$optionKey};
foreach my $optionKey (sort {"\L${$self->get('options')}{$a}" cmp "\L${$self->get('options')}{$b}" } keys %{$self->get('options')}) {
$options{$optionKey} = $self->get('options')->{$optionKey};
}
} else {
%options = %{$self->{options}};
%options = %{$self->get('options')};
}
return %options;
}

View file

@ -92,7 +92,7 @@ Renders an input tag of type password.
sub toHtml {
my $self = shift;
my $html = '<input type="password" name="'.$self->get("name").'" value="'.$self->fixQuotes($self->get("value")).'" size="'.$self->get("size").'" id="'.$self->{id}.'" ';
my $html = '<input type="password" name="'.$self->get("name").'" value="'.$self->fixQuotes($self->get("value")).'" size="'.$self->get("size").'" id="'.$self->get('id').'" ';
$html .= 'maxlength="'.$self->get("maxLength").'" ' if ($self->get("maxLength"));
$html .= $self->get("extras").' />';
return $html;

View file

@ -100,7 +100,7 @@ sub toHtml {
my $self = shift;
my $value = $self->fixMacros($self->fixQuotes($self->fixSpecialCharacters($self->get("value"))));
my $checkedText = ' checked="checked"' if ($self->get("checked"));
my $idText = ' id="'.$self->{id}.'" ' if ($self->{id});
my $idText = ' id="'.$self->get('id').'" ' if ($self->get('id'));
return '<input type="radio" name="'.$self->get("name").'" value="'.$value.'"'.$idText.$checkedText.' '.$self->get("extras").' />';
}

View file

@ -105,16 +105,16 @@ sub toHtml {
%options = $self->orderedHash;
foreach my $key (keys %options) {
my $checked = 0;
if ($self->get("value") eq $key) {
if ($self->get('value') eq $key) {
$checked = 1;
}
$output .= WebGUI::Form::Radio->new({
name=>$self->get("name"),
name=>$self->get('name'),
value=>$key,
extras=>$self->get("extras"),
extras=>$self->get('extras'),
checked=>$checked
})->toHtml;
$output .= ${$self->get("options}"){$key} . $alignment;
$output .= $self->get('options')->{$key} . $alignment;
}
return $output;
}

View file

@ -113,7 +113,7 @@ Renders a select list form control.
sub toHtml {
my $self = shift;
my $output = '<select name="'.$self->get("name").'" size="'.$self->get("size").'" id="'.$self->{id}.'" '.$self->get("extras").'>';
my $output = '<select name="'.$self->get("name").'" size="'.$self->get("size").'" id="'.$self->get('id').'" '.$self->get("extras").'>';
my %options;
tie %options, 'Tie::IxHash';
%options = $self->orderedHash;
@ -123,7 +123,7 @@ sub toHtml {
if ($value eq $key) {
$output .= ' selected="selected"';
}
$output .= '>'.${$self->{options}}{$key}.'</option>';
$output .= '>'.$self->get('options')->{$key}.'</option>';
}
$output .= '</select>'."\n";
return $output;

View file

@ -93,7 +93,7 @@ Renders a select list form control.
sub toHtml {
my $self = shift;
my $multiple = ' multiple="1"' if ($self->get("multiple"));
my $output = '<select name="'.$self->get("name").'" size="'.$self->get("size").'" id="'.$self->{id}.'" '.$self->get("extras").$multiple.'>';
my $output = '<select name="'.$self->get("name").'" size="'.$self->get("size").'" id="'.$self->get('id').'" '.$self->get("extras").$multiple.'>';
my %options;
tie %options, 'Tie::IxHash';
%options = $self->orderedHash;

View file

@ -72,7 +72,7 @@ sub toHtml {
$self->{_params}{extras}; ||= 'onclick="this.value=\''.$i18n->get(452).'\'"';
my $html = '<input type="submit" ';
$html .= 'name="'.$self->get("name").'" ' if ($self->get("name"));
$html .= 'id="'.$self->{id}.'" ' unless ($self->{id} eq "_formId");
$html .= 'id="'.$self->get('id').'" ' unless ($self->get('id') eq "_formId");
$html .= 'value="'.$value.'" '.$self->get("extras").' />';
return $html;
}

View file

@ -131,10 +131,10 @@ editing the template show up if the user is allowed to do that.
sub setManageIcons {
my $self = shift;
my $template = WebGUI::Asset::Template->new($self->get("value"));
my $template = WebGUI::Asset::Template->new($self->get('value'));
if (defined $template && $template->canEdit) {
my $returnUrl;
if (exists $self->session->asset) {
if (defined $self->session->asset && ref $self->session->asset eq "WebGUI::Asset::Template") {
$returnUrl = ";proceed=goBackToPage;returnUrl=".$self->session->url->escape($self->session->asset->getUrl);
}
my $buttons = $self->session->icon->edit("func=edit".$returnUrl,$template->get("url"));

View file

@ -93,7 +93,7 @@ Renders an input tag of type text.
sub toHtml {
my $self = shift;
my $value = $self->fixMacros($self->fixQuotes($self->fixSpecialCharacters($self->get("value"))));
return '<input id="'.$self->{id}.'" type="text" name="'.$self->get("name").'" value="'.$value.'" size="'.$self->get("size").'" maxlength="'.$self->get("maxlength").'" '.$self->get("extras").' />';
return '<input id="'.$self->get('id').'" type="text" name="'.$self->get("name").'" value="'.$value.'" size="'.$self->get("size").'" maxlength="'.$self->get("maxlength").'" '.$self->get("extras").' />';
}
1;

View file

@ -100,7 +100,7 @@ Renders an input tag of type text.
sub toHtml {
my $self = shift;
my $value = $self->fixMacros($self->fixTags($self->fixSpecialCharacters($self->get("value"))));
return '<textarea id="'.$self->{id}.'" name="'.$self->get("name").'" cols="'.$self->get("columns").'" rows="'.$self->get("rows").'" wrap="'.
return '<textarea id="'.$self->get('id').'" name="'.$self->get("name").'" cols="'.$self->get("columns").'" rows="'.$self->get("rows").'" wrap="'.
$self->get("wrap").'" '.$self->get("extras").'>'.$value.'</textarea>';
}

View file

@ -113,7 +113,7 @@ sub toHtml {
$self->get("extras") .= ' onkeyup="doInputCheck(this.form.'.$self->get("name").',\'0123456789:\')"';
return $self->SUPER::toHtml
.WebGUI::Form::Button->new(
id=>$self->{id},
id=>$self->get('id'),
extras=>'style="font-size: 8pt;" onclick="window.timeField = this.form.'.$self->get("name").';clockSet = window.open(\''.$self->session->config->get("extrasURL"). '/timeChooser.html\',\'timeChooser\',\'WIDTH=230,HEIGHT=100\');return false"',
value=>$i18n->get(970)
)->toHtml;