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
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue