aboutsummaryrefslogtreecommitdiffstats
path: root/root/base/form_base
blob: cb988ecd1ba698ccd734c4365201b5b01381b1c3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
[%

main_block    = 'form_base_control';

control_block = 'form_base_control';

header_block  = 'form_base_header';
fields_block  = 'form_base_fields';
button_block  = 'form_base_buttons';
footer_block  = 'form_base_footer';

form_id = 0;

BLOCK form_base_control;

  form_id = form_id + 1;

  enctype = attrs.enctype || 'multipart/form-data';
  %]<form action="[% attrs.action || connect_form %]" method="post" id="element_[% form_id %]" enctype="[% enctype %]"[%
  IF attrs.name != ""; ' name="'; attrs.name; attrs.name = ''; '"'; END;
  attrs.enctype = ''; attrs.action = '';
  process_attrs(self.attrs) %]>[% "\n";

  include( 'header_block' );
  include( 'fields_block' );

  id_attr = ''; '<p>';
  include( 'button_block' );
  include( 'footer_block' );

  "</p>\n</form>";

END;

BLOCK form_base_header;

  '';

END;

BLOCK form_base_fields;

  FOREACH f_name = self.field_names;
    field = self.fields.$f_name;
    id    = form_id _ '_' _ loop.count;
    '<p>'; window.render_viewport(field); "</p>\n";
  END;

END;

BLOCK form_base_buttons;

  allowed_events = self.accept_events;

  IF allowed_events.grep('^ok$').size;
    INCLUDE component type = 'submitbtn' self.value = 'ok' self.event = 'ok' self.label = self.ok_label;
  END;

  IF (self.field_names.size != 0) && (allowed_events.grep('^apply$').size);
    INCLUDE component type = 'submitbtn' self.value = 'apply' self.event = 'apply' self.label = self.apply_label;
  END;

  IF allowed_events.grep('^close$').size;
    INCLUDE component type = 'cancelbtn' self.value = 'cancel' self.event = 'close' self.label = self.cancel_label;
  END;

END;

BLOCK form_base_footer;

  IF self.message;
    ' <span>'; self.message; '</span>';
  END;

END;

%]