Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 11e4b8f3

Von Moritz Bunkus vor fast 14 Jahren hinzugefügt

  • ID 11e4b8f332482c1becab9e099181b7cf44b88b09
  • Vorgänger 094aaf62
  • Nachfolger 62ba378c

Hilfsfunktionen textarea_tag und radiobutton_tag

Unterschiede anzeigen:

SL/Template/Plugin/L.pm
60 60
  my $content    = shift;
61 61
  my $attributes = $self->attributes(@_);
62 62

  
63
  return "<${tag}${attributes}/>" unless $content;
63
  return "<${tag}${attributes}/>" unless defined($content);
64 64
  return "<${tag}${attributes}>${content}</${tag}>";
65 65
}
66 66

  
......
75 75
  return $self->html_tag('select', $options_str, %attributes, name => $name);
76 76
}
77 77

  
78
sub textarea_tag {
79
  my $self            = shift;
80
  my $name            = shift;
81
  my $content         = shift;
82
  my %attributes      = _hashify(@_);
83

  
84
  $attributes{id}   ||= $self->name_to_id($name);
85
  $content            = $content ? '' : _H($content);
86

  
87
  return $self->html_tag('textarea', $content, %attributes, name => $name);
88
}
89

  
78 90
sub checkbox_tag {
79 91
  my $self             = shift;
80 92
  my $name             = shift;
......
96 108
  return $code;
97 109
}
98 110

  
111
sub radio_button_tag {
112
  my $self             = shift;
113
  my $name             = shift;
114
  my %attributes       = _hashify(@_);
115

  
116
  $attributes{value}   = 1 unless defined $attributes{value};
117
  $attributes{id}    ||= $self->name_to_id($name . "_" . $attributes{value});
118
  my $label            = delete $attributes{label};
119

  
120
  if ($attributes{checked}) {
121
    $attributes{checked} = 'checked';
122
  } else {
123
    delete $attributes{checked};
124
  }
125

  
126
  my $code  = $self->html_tag('input', undef,  %attributes, name => $name, type => 'radio');
127
  $code    .= $self->html_tag('label', $label, for => $attributes{id}) if $label;
128

  
129
  return $code;
130
}
131

  
99 132
sub input_tag {
100 133
  my $self            = shift;
101 134
  my $name            = shift;
......
243 276
C<$value> and with arbitrary HTML attributes from C<%attributes>. The
244 277
tag's C<id> defaults to C<name_to_id($name)>.
245 278

  
279
=item C<textarea_tag $name, $value, %attributes>
280

  
281
Creates a HTML 'textarea' tag named C<$name> with the content
282
C<$value> and with arbitrary HTML attributes from C<%attributes>. The
283
tag's C<id> defaults to C<name_to_id($name)>.
284

  
246 285
=item C<checkbox_tag $name, %attributes>
247 286

  
248 287
Creates a HTML 'input type=checkbox' tag named C<$name> with arbitrary
......
253 292
created with said C<label>. No attribute named C<label> is created in
254 293
that case.
255 294

  
256
=item C<date_tag $name, $value, %attributes>
257

  
258 295
=item C<date_tag $name, $value, cal_align =E<gt> $align_code, %attributes>
259 296

  
260 297
Creates a date input field, with an attached javascript that will open a
......
263 300
the details, usually you'll want a two letter abbreviation of the alignment.
264 301
Right + Bottom becomes C<BL>.
265 302

  
303
=item C<radio_button_tag $name, %attributes>
304

  
305
Creates a HTML 'input type=radio' tag named C<$name> with arbitrary
306
HTML attributes from C<%attributes>. The tag's C<value> defaults to
307
C<1>. The tag's C<id> defaults to C<name_to_id($name . "_" . $value)>.
308

  
309
If C<%attributes> contains a key C<label> then a HTML 'label' tag is
310
created with said C<label>. No attribute named C<label> is created in
311
that case.
312

  
266 313
=back
267 314

  
268 315
=head2 CONVERSION FUNCTIONS

Auch abrufbar als: Unified diff