+sub radio_button_tag {
+ my ($name, %attributes) = @_;
+
+ $attributes{value} = 1 unless exists $attributes{value};
+
+ _set_id_attribute(\%attributes, $name, 1);
+ my $label = delete $attributes{label};
+
+ _set_id_attribute(\%attributes, $name . '_' . $attributes{value});
+
+ if ($attributes{checked}) {
+ $attributes{checked} = 'checked';
+ } else {
+ delete $attributes{checked};
+ }
+
+ my $code = html_tag('input', undef, %attributes, name => $name, type => 'radio');
+ $code .= html_tag('label', $label, for => $attributes{id}) if $label;
+
+ return $code;
+}
+
+sub button_tag {
+ my ($onclick, $value, %attributes) = @_;
+
+ _set_id_attribute(\%attributes, $attributes{name}) if $attributes{name};
+ $attributes{type} ||= 'button';
+
+ $onclick = 'if (!confirm("'. _J(delete($attributes{confirm})) .'")) return false; ' . $onclick if $attributes{confirm};
+
+ html_tag('input', undef, %attributes, value => $value, onclick => $onclick);
+}
+
+sub submit_tag {
+ my ($name, $value, %attributes) = @_;
+
+ _set_id_attribute(\%attributes, $attributes{name}) if $attributes{name};
+
+ if ( $attributes{confirm} ) {
+ $attributes{onclick} = 'return confirm("'. _J(delete($attributes{confirm})) .'");';
+ }
+
+ input_tag($name, $value, %attributes, type => 'submit', class => 'submit');
+}
+
+sub ajax_submit_tag {
+ my ($url, $form_selector, $text, %attributes) = @_;
+
+ $url = _J($url);
+ $form_selector = _J($form_selector);
+ my $onclick = qq|kivi.submit_ajax_form('${url}', '${form_selector}')|;
+
+ button_tag($onclick, $text, %attributes);
+}
+
+sub input_number_tag {
+ my ($name, $value, %params) = @_;
+
+ _set_id_attribute(\%params, $name);
+ my @onchange = $params{onchange} ? (onChange => delete $params{onchange}) : ();
+ my @classes = ('numeric');
+ push @classes, delete($params{class}) if $params{class};
+ my %class = @classes ? (class => join(' ', @classes)) : ();
+
+ $::request->layout->add_javascripts('kivi.Validator.js');
+ $::request->presenter->need_reinit_widgets($params{id});
+
+ input_tag(
+ $name, $::form->format_amount(\%::myconfig, $value, $params{precision}),
+ "data-validate" => "number",
+ %params,
+ %class, @onchange,
+ );
+}
+
+