added automatic id attribute generation to all form controls
This commit is contained in:
parent
3058d839c0
commit
4c8ff049cc
29 changed files with 116 additions and 25 deletions
|
|
@ -2979,7 +2979,8 @@ sub www_editTree {
|
|||
-subtext=>'<br />'.WebGUI::International::get("change","Asset").' '.WebGUI::Form::yesNo({name=>"change_url"}),
|
||||
-value=>WebGUI::Form::selectList({
|
||||
name=>"baseUrlBy",
|
||||
extras=>'id="baseUrlBy" onchange="toggleSpecificBaseUrl()"',
|
||||
extras=>'onchange="toggleSpecificBaseUrl()"',
|
||||
id=>"baseUrlBy",
|
||||
options=>{
|
||||
parentUrl=>"Parent URL",
|
||||
specifiedBase=>"Specified Base",
|
||||
|
|
|
|||
|
|
@ -120,7 +120,8 @@ sub getEditForm {
|
|||
-value=>[$self->getValue("startType")],
|
||||
-label=>$i18n->get("Start Point Type"),
|
||||
-hoverHelp=>$i18n->get("Start Point Type description"),
|
||||
-extras=>'id="navStartType" onChange="changeStartPoint()"'
|
||||
-id=>"navStartType",
|
||||
-extras=>'onchange="changeStartPoint()"'
|
||||
);
|
||||
$tabform->getTab("properties")->readOnly(
|
||||
-label=>$i18n->get("Start Point"),
|
||||
|
|
|
|||
|
|
@ -89,6 +89,10 @@ Add extra attributes to the form tag like
|
|||
|
||||
A text label that will be displayed if toHtmlWithWrapper() is called.
|
||||
|
||||
=head4 id
|
||||
|
||||
A unique identifier that can be used to identify this field with javascripts and cascading style sheets. Is autogenerated if not specified. The autogenerated version is the value of the name parameter concatinated with the string "_formId". So for a field called "title" it would be "title_formId".
|
||||
|
||||
=head4 uiLevel
|
||||
|
||||
The UI Level that the user must meet or exceed if this field should be displayed with toHtmlWithWrapper() is called.
|
||||
|
|
@ -159,6 +163,9 @@ sub definition {
|
|||
defaultValue=>undef
|
||||
},
|
||||
subtext=>{
|
||||
defaultValue=>undef
|
||||
},
|
||||
id=>{
|
||||
defaultValue=>undef
|
||||
}
|
||||
});
|
||||
|
|
@ -167,6 +174,24 @@ sub definition {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 generateIdParameter ( name )
|
||||
|
||||
A class method that returns a value to be used as the autogenerated ID for this field instance. Unless overriden, it simply returns the name with "_formId" appended to it.
|
||||
|
||||
=head3 name
|
||||
|
||||
The name of the field.
|
||||
|
||||
=cut
|
||||
|
||||
sub generateIdParameter {
|
||||
my $class = shift;
|
||||
my $name = shift;
|
||||
return $name."_formId";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getName ( )
|
||||
|
||||
Returns a human readable name for this form control type. You MUST override this method with your own when creating new form controls.
|
||||
|
|
@ -323,6 +348,10 @@ sub new {
|
|||
unless (exists $params{value}) {
|
||||
$params{value} = $params{defaultValue};
|
||||
}
|
||||
# doesn't have an id specified, so let's give it one
|
||||
unless ($params{id}) {
|
||||
$params{id} = $class->generateIdParameter($params{name});
|
||||
}
|
||||
bless \%params, $class;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -122,8 +122,8 @@ Renders an HTML area field.
|
|||
sub toHtml {
|
||||
my $self = shift;
|
||||
WebGUI::Style::setScript($session{config}{extrasURL}.'/textFix.js',{ type=>'text/javascript' });
|
||||
$self->{extras} .= ' id="'.$self->{name}.'" onBlur="fixChars(this.form.'.$self->{name}.')" mce_editable="true" ';
|
||||
return $self->SUPER::toHtml.WebGUI::Asset::RichEdit->new($self->{richEditId})->getRichEditor($self->{name});
|
||||
$self->{extras} .= ' onblur="fixChars(this.form.'.$self->{name}.')" mce_editable="true" ';
|
||||
return $self->SUPER::toHtml.WebGUI::Asset::RichEdit->new($self->{richEditId})->getRichEditor($self->{id});
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -109,17 +109,19 @@ sub toHtml {
|
|||
my $asset = WebGUI::Asset->newByDynamicClass($self->{value}) || WebGUI::Asset->getRoot;
|
||||
return WebGUI::Form::hidden->new(
|
||||
name=>$self->{name},
|
||||
extras=>'id="'.$self->{name}.'" '.$self->{extras},
|
||||
value=>$asset->getId
|
||||
extras=>$self->{extras},
|
||||
value=>$asset->getId,
|
||||
id=>$self->{id}
|
||||
)->toHtml
|
||||
.WebGUI::Form::text->new(
|
||||
name=>$self->{name}."_display",
|
||||
extras=>'id="'.$self->{name}."_display".'" readonly="1"',
|
||||
value=>$asset->get("title")
|
||||
extras=>' readonly="1" ',
|
||||
value=>$asset->get("title"),
|
||||
id=>$self->{id}."_display"
|
||||
)->toHtml
|
||||
.WebGUI::Form::button->new(
|
||||
value=>"...",
|
||||
extras=>'onclick="window.open(\''.$asset->getUrl("op=formAssetTree&classLimiter=".$self->{class}."&formId=".$self->{name}).'\',\'assetPicker\',\'toolbar=no, location=no, status=no, directories=no, width=400, height=400\');"'
|
||||
extras=>'onclick="window.open(\''.$asset->getUrl("op=formAssetTree&classLimiter=".$self->{class}."&formId=".$self->{id}).'\',\'assetPicker\',\'toolbar=no, location=no, status=no, directories=no, width=400, height=400\');"'
|
||||
)->toHtml;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ Renders a button.
|
|||
sub toHtml {
|
||||
my $self = shift;
|
||||
my $value = $self->fixQuotes($self->{value});
|
||||
return '<input type="button" name="'.$self->{name}.'" value="'.$value.'" '.$self->{extras}.' />';
|
||||
return '<input type="button" name="'.$self->{name}.'" value="'.$value.'" id="'.$self->{id}.'" '.$self->{extras}.' />';
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -72,6 +72,18 @@ sub definition {
|
|||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 generateIdParameter ( )
|
||||
|
||||
A class method that returns a value to be used as the autogenerated ID for this field instance. Returns undef because this field type can have more than one with the same name, therefore autogenerated ID's aren't terribly useful.
|
||||
|
||||
=cut
|
||||
|
||||
sub generateIdParameter {
|
||||
return undef
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getName ()
|
||||
|
|
@ -97,7 +109,8 @@ sub toHtml {
|
|||
my $self = shift;
|
||||
my $value = $self->fixMacros($self->fixQuotes($self->fixSpecialCharacters($self->{value})));
|
||||
my $checkedText = ' checked="checked"' if ($self->{checked});
|
||||
return '<input type="checkbox" name="'.$self->{name}.'" value="'.$value.'"'.$checkedText.' '.$self->{extras}.' />';
|
||||
my $idText = ' id="'.$self->{id}.'" ' if ($self->{id});
|
||||
return '<input type="checkbox" name="'.$self->{name}.'" value="'.$value.'"'.$idText.$checkedText.' '.$self->{extras}.' />';
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -83,7 +83,8 @@ sub toHtml {
|
|||
return $self->SUPER::toHtml
|
||||
.WebGUI::Form::text->new(
|
||||
size=>$session{setting}{textBoxSize}-5,
|
||||
name=>$self->{name}."_new"
|
||||
name=>$self->{name}."_new",
|
||||
id=>$self->{id}."_new"
|
||||
)->toHtml;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -130,6 +130,7 @@ sub toHtml {
|
|||
}
|
||||
return WebGUI::Form::selectList->new(
|
||||
options=>\%types,
|
||||
id=>$self->{id},
|
||||
name=>$self->{name},
|
||||
value=>[$self->{value}],
|
||||
extras=>$self->{extras},
|
||||
|
|
|
|||
|
|
@ -120,6 +120,7 @@ Renders a database connection picker control.
|
|||
sub toHtml {
|
||||
my $self = shift;
|
||||
return WebGUI::Form::selectList->new(
|
||||
id=>$self->{id},
|
||||
name=>$self->{name},
|
||||
options=>WebGUI::DatabaseLink::getList(),
|
||||
value=>[$self->{value}],
|
||||
|
|
|
|||
|
|
@ -133,11 +133,12 @@ sub toHtml {
|
|||
name=>$self->{name},
|
||||
value=>$value,
|
||||
size=>$self->{size},
|
||||
extras=>'id="'.$self->{name}.'Id" '.$self->{extras},
|
||||
extras=>$self->{extras},
|
||||
id=>$self->{id},
|
||||
maxlength=>$self->{maxlength}
|
||||
)->toHtml . '<script type="text/javascript">
|
||||
Calendar.setup({
|
||||
inputField : "'.$self->{name}.'Id",
|
||||
inputField : "'.$self->{id}.'",
|
||||
ifFormat : "%Y-%m-%d",
|
||||
showsTime : false,
|
||||
timeFormat : "12",
|
||||
|
|
|
|||
|
|
@ -126,11 +126,12 @@ sub toHtml {
|
|||
name=>$self->{name},
|
||||
value=>$value,
|
||||
size=>$self->{size},
|
||||
extras=>'id="'.$self->{name}.'Id" '.$self->{extras},
|
||||
extras=>$self->{extras},
|
||||
id=>$self->{id},
|
||||
maxlength=>$self->{maxlength}
|
||||
)->toHtml . '<script type="text/javascript">
|
||||
Calendar.setup({
|
||||
inputField : "'.$self->{name}.'Id",
|
||||
inputField : "'.$self->{name}.'",
|
||||
ifFormat : "%Y-%m-%d %H:%M:%S",
|
||||
showsTime : true,
|
||||
timeFormat : "12",
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ Renders an email address field.
|
|||
sub toHtml {
|
||||
my $self = shift;
|
||||
WebGUI::Style::setScript($session{config}{extrasURL}.'/emailCheck.js',{ type=>'text/javascript' });
|
||||
$self->{extras} .= ' onChange="emailCheck(this.value)" ';
|
||||
$self->{extras} .= ' onchange="emailCheck(this.value)" ';
|
||||
return $self->SUPER::toHtml;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -149,6 +149,7 @@ sub toHtml {
|
|||
$options{$type} = $class->getName;
|
||||
}
|
||||
return WebGUI::Form::selectList->new(
|
||||
id=>$self->{id},
|
||||
name=>$self->{name},
|
||||
options=>\%options,
|
||||
value=>[$self->{value}],
|
||||
|
|
|
|||
|
|
@ -127,6 +127,7 @@ sub toHtml {
|
|||
'all'=>WebGUI::International::get(419)
|
||||
);
|
||||
return WebGUI::Form::selectList->new(
|
||||
id=>$self->{id},
|
||||
options=>\%filter,
|
||||
name=>$self->{name},
|
||||
value=>[$self->{value}],
|
||||
|
|
|
|||
|
|
@ -145,6 +145,7 @@ sub toHtml {
|
|||
return WebGUI::Form::selectList->new(
|
||||
options=>WebGUI::SQL->buildHashRef("select groupId,groupName from groups where showInForms=1 $where order by groupName"),
|
||||
name=>$self->{name},
|
||||
id=>$self->{id},
|
||||
value=>$self->{value},
|
||||
extras=>$self->{extras},
|
||||
size=>$self->{size},
|
||||
|
|
|
|||
|
|
@ -39,6 +39,18 @@ The following methods are specifically available from this class. Check the supe
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 generateIdParameter ( )
|
||||
|
||||
A class method that returns a value to be used as the autogenerated ID for this field instance. Returns undef because this field type can have more than one with the same name, therefore autogenerated ID's aren't terribly useful.
|
||||
|
||||
=cut
|
||||
|
||||
sub generateIdParameter {
|
||||
return undef
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getName ()
|
||||
|
||||
Returns the human readable name or type of this form control.
|
||||
|
|
@ -74,7 +86,8 @@ Renders an input tag of type hidden.
|
|||
sub toHtmlAsHidden {
|
||||
my $self = shift;
|
||||
my $value = $self->fixMacros($self->fixQuotes($self->fixSpecialCharacters($self->{value})));
|
||||
return '<input type="hidden" name="'.$self->{name}.'" value="'.$value.'" '.$self->{extras}.' />'."\n";
|
||||
my $idText = ' id="'.$self->{id}.'" ' if ($self->{id});
|
||||
return '<input type="hidden" name="'.$self->{name}.'" value="'.$value.'" '.$self->{extras}.$idText.' />'."\n";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -120,10 +120,12 @@ sub toHtml {
|
|||
name=>$self->{name}."_interval",
|
||||
value=>$interval,
|
||||
extras=>$self->{extras}
|
||||
id=>$self->{id}."_interval",
|
||||
)->toHtml
|
||||
.WebGUI::Form::selectList->new(
|
||||
options=>\%units,
|
||||
name=>$self->{name}."_units",
|
||||
id=>$self->{id}."_units",
|
||||
value=>[$self->{value}]
|
||||
)->toHtml;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -142,6 +142,7 @@ sub toHtml {
|
|||
my $self = shift;
|
||||
return WebGUI::Form::selectList->new(
|
||||
name=>$self->{name},
|
||||
id=>$self->{id},
|
||||
options=>WebGUI::LDAPLink::getList(),
|
||||
value=>$self->{value},
|
||||
multiple=>$self->{multiple},
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ Renders an input tag of type password.
|
|||
sub toHtml {
|
||||
my $self = shift;
|
||||
return '<input type="password" name="'.$self->{name}.'" value="'.$self->fixQuotes($self->{value}).'" size="'.
|
||||
$self->{size}.'" maxlength="'.$self->{maxLength}.'" '.$self->{extras}.' />';
|
||||
$self->{size}.'" id="'.$self->{id}.'" maxlength="'.$self->{maxLength}.'" '.$self->{extras}.' />';
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -65,6 +65,18 @@ sub definition {
|
|||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 generateIdParameter ( )
|
||||
|
||||
A class method that returns a value to be used as the autogenerated ID for this field instance. Returns undef because this field type can have more than one with the same name, therefore autogenerated ID's aren't terribly useful.
|
||||
|
||||
=cut
|
||||
|
||||
sub generateIdParameter {
|
||||
return undef
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getName ()
|
||||
|
|
@ -90,7 +102,8 @@ sub toHtml {
|
|||
my $self = shift;
|
||||
my $value = $self->fixMacros($self->fixQuotes($self->fixSpecialCharacters($self->{value})));
|
||||
my $checkedText = ' checked="checked"' if ($self->{checked});
|
||||
return '<input type="radio" name="'.$self->{name}.'" value="'.$value.'"'.$checkedText.' '.$self->{extras}.' />';
|
||||
my $idText = ' id="'.$self->{id}.'" ' if ($self->{id});
|
||||
return '<input type="radio" name="'.$self->{name}.'" value="'.$value.'"'.$idText.$checkedText.' '.$self->{extras}.' />';
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ Renders a select list form control.
|
|||
sub toHtml {
|
||||
my $self = shift;
|
||||
my $multiple = ' multiple="1"' if ($self->{multiple});
|
||||
my $output = '<select name="'.$self->{name}.'" size="'.$self->{size}.'" '.$self->{extras}.$multiple.'>';
|
||||
my $output = '<select name="'.$self->{name}.'" size="'.$self->{size}.'" id="'.$self->{id}.'" '.$self->{extras}.$multiple.'>';
|
||||
my %options;
|
||||
tie %options, 'Tie::IxHash';
|
||||
if ($self->{sortByValue}) {
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ sub toHtml {
|
|||
my $self = shift;
|
||||
my $value = $self->fixQuotes($self->{value});
|
||||
$self->{extras} ||= 'onclick="this.value=\''.WebGUI::International::get(452).'\'"';
|
||||
return '<input type="submit" name="'.$self->{name}.'" value="'.$value.'" '.$self->{extras}.' />';
|
||||
return '<input id="'.$self->{id}.'" type="submit" name="'.$self->{name}.'" value="'.$value.'" '.$self->{extras}.' />';
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -113,6 +113,7 @@ sub toHtml {
|
|||
}
|
||||
}
|
||||
return WebGUI::Form::selectList->new(
|
||||
id=>$self->{id},
|
||||
name=>$self->{name},
|
||||
options=>$templateList,
|
||||
value=>[$self->{value}],
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ Renders an input tag of type text.
|
|||
sub toHtml {
|
||||
my $self = shift;
|
||||
my $value = $self->fixMacros($self->fixQuotes($self->fixSpecialCharacters($self->{value})));
|
||||
return '<input type="text" name="'.$self->{name}.'" value="'.$value.'" size="'.$self->{size}.'" maxlength="'.$self->{maxlength}.'" '.$self->{extras}.' />';
|
||||
return '<input id="'.$self->{id}.'" type="text" name="'.$self->{name}.'" value="'.$value.'" size="'.$self->{size}.'" maxlength="'.$self->{maxlength}.'" '.$self->{extras}.' />';
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ Renders an input tag of type text.
|
|||
sub toHtml {
|
||||
my $self = shift;
|
||||
my $value = $self->fixMacros($self->fixTags($self->fixSpecialCharacters($self->{value})));
|
||||
return '<textarea name="'.$self->{name}.'" cols="'.$self->{columns}.'" rows="'.$self->{rows}.'" wrap="'.
|
||||
return '<textarea id="'.$self->{id}.'" name="'.$self->{name}.'" cols="'.$self->{columns}.'" rows="'.$self->{rows}.'" wrap="'.
|
||||
$self->{wrap}.'" '.$self->{extras}.'>'.$value.'</textarea>';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -117,6 +117,7 @@ sub toHtml {
|
|||
$self->{extras} .= ' onkeyup="doInputCheck(this.form.'.$self->{name}.',\'0123456789:\')"';
|
||||
return $self->SUPER::toHtml
|
||||
.WebGUI::Form::button->new(
|
||||
id=>$self->{id},
|
||||
extras=>'style="font-size: 8pt;" onClick="window.timeField = this.form.'.$self->{name}.';clockSet = window.open(\''.$session{config}{extrasURL}. '/timeChooser.html\',\'timeChooser\',\'WIDTH=230,HEIGHT=100\');return false"',
|
||||
value=>WebGUI::International::get(970)
|
||||
)->toHtml;
|
||||
|
|
|
|||
|
|
@ -107,6 +107,7 @@ Renders a question selector asking the user where they want to go.
|
|||
sub toHtml {
|
||||
my $self = shift;
|
||||
return WebGUI::Form::selectList->new(
|
||||
id=>$self->{id},
|
||||
name=>$self->{name},
|
||||
options=>$self->{options},
|
||||
value=>[$self->{value}],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue