Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 94ca5d51

Von Bernd Bleßmann vor mehr als 3 Jahren hinzugefügt

  • ID 94ca5d5182fbe9e07ac9217f191751a156bd230f
  • Vorgänger 05ec7365
  • Nachfolger d6a9eb6c

Presenter::Tag: radio_button_tag aus Plugin/L verschoben

Unterschiede anzeigen:

SL/Presenter/Tag.pm
11 11
  html_tag input_tag hidden_tag javascript man_days_tag name_to_id select_tag
12 12
  checkbox_tag button_tag submit_tag ajax_submit_tag input_number_tag
13 13
  stringify_attributes restricted_html textarea_tag link_tag date_tag
14
  div_tag);
14
  div_tag radio_button_tag);
15 15
our %EXPORT_TAGS = (ALL => \@EXPORT_OK);
16 16

  
17 17
use Carp;
......
259 259
  return $code;
260 260
}
261 261

  
262
sub radio_button_tag {
263
  my ($name, %attributes) = @_;
264

  
265
  $attributes{value}   = 1 unless exists $attributes{value};
266

  
267
  _set_id_attribute(\%attributes, $name, 1);
268
  my $label            = delete $attributes{label};
269

  
270
  _set_id_attribute(\%attributes, $name . '_' . $attributes{value});
271

  
272
  if ($attributes{checked}) {
273
    $attributes{checked} = 'checked';
274
  } else {
275
    delete $attributes{checked};
276
  }
277

  
278
  my $code  = html_tag('input', undef,  %attributes, name => $name, type => 'radio');
279
  $code    .= html_tag('label', $label, for => $attributes{id}) if $label;
280

  
281
  return $code;
282
}
283

  
262 284
sub button_tag {
263 285
  my ($onclick, $value, %attributes) = @_;
264 286

  
......
540 562
JQuery selector and clicking this checkbox will also toggle all checkboxes
541 563
matching the selector.
542 564

  
565
=item C<radio_button_tag $name, %attributes>
566

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

  
571
If C<%attributes> contains a key C<label> then a HTML 'label' tag is
572
created with said C<label>. No attribute named C<label> is created in
573
that case.
574

  
543 575
=item C<select_tag $name, \@collection, %attributes>
544 576

  
545 577
Creates an HTML 'select' tag named C<$name> with the contents of one
SL/Template/Plugin/L.pm
83 83
sub textarea_tag             { return _call_presenter('textarea_tag',             @_); }
84 84
sub date_tag                 { return _call_presenter('date_tag',                 @_); }
85 85
sub div_tag                  { return _call_presenter('div_tag',                  @_); }
86
sub radio_button_tag         { return _call_presenter('radio_button_tag',         @_); }
86 87

  
87 88
sub _set_id_attribute {
88 89
  my ($attributes, $name, $unique) = @_;
......
97 98
  return $self->html_tag('img', undef, %options);
98 99
}
99 100

  
100
sub radio_button_tag {
101
  my ($self, $name, %attributes) = _hashify(2, @_);
102

  
103
  $attributes{value}   = 1 unless exists $attributes{value};
104

  
105
  _set_id_attribute(\%attributes, $name, 1);
106
  my $label            = delete $attributes{label};
107

  
108
  _set_id_attribute(\%attributes, $name . '_' . $attributes{value});
109

  
110
  if ($attributes{checked}) {
111
    $attributes{checked} = 'checked';
112
  } else {
113
    delete $attributes{checked};
114
  }
115

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

  
119
  return $code;
120
}
121

  
122 101
sub ul_tag {
123 102
  my ($self, $content, @slurp) = @_;
124 103
  return $self->html_tag('ul', $content, @slurp);
......
484 463
Creates a date input field, with an attached javascript that will open a
485 464
calendar on click.
486 465

  
487
=item C<radio_button_tag $name, %attributes>
488

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

  
493
If C<%attributes> contains a key C<label> then a HTML 'label' tag is
494
created with said C<label>. No attribute named C<label> is created in
495
that case.
496

  
497 466
=item C<javascript_tag $file1, $file2, $file3...>
498 467

  
499 468
Creates a HTML 'E<lt>script type="text/javascript" src="..."E<gt>'

Auch abrufbar als: Unified diff