99320f1767592ec1a52b64ee57219abde0e0550a.svn-base 8.65 KB
Newer Older
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279

<!-- Display the fields -->
{*	
	Contents:
	---------
	
	#00 - Introduction/ Comments
	#01 - Sections loop
		#02 - Scriptaculous collapsible bar.
		#03 - Inner elements loop
		
	

	#00 - Introduction /Comments
	-----------------------------
	This template displays an entire HTML QuickForm form.  It is designed to 
	be used with the HTML_QuickForm_Renderer_ArrayDataface class which produces
	an array of the form:
	 array(
   'frozen'           => 'whether the form is frozen',
   'javascript'       => 'javascript for client-side validation',
   'attributes'       => 'attributes for <form> tag',
   'requirednote      => 'note about the required elements',
   // if we set the option to collect hidden elements
   'hidden'           => 'collected html of all hidden elements',
   // if there were some validation errors:
   'errors' => array(
     '1st element name' => 'Error for the 1st element',
     ...
     'nth element name' => 'Error for the nth element'
   ),
   // if there are no headers in the form:
   'elements' => array(
     element_1,
     ...
     element_N
   )
   // if there are headers in the form:
   'sections' => array(
     array(
       'header'   => 'Header text for the first header',
       'name'     => 'Header name for the first header',
       'elements' => array(
          element_1,
          ...
          element_K1
       )
     ),
     ...
     array(
       'header'   => 'Header text for the Mth header',
       'name'     => 'Header name for the Mth header',
       'elements' => array(
          element_1,
          ...
          element_KM
       )
     )
   )
 );

 where element_i is an array of the form:
 array(
   'name'      => 'element name',
   'value'     => 'element value',
   'type'      => 'type of the element',
   'frozen'    => 'whether element is frozen',
   'label'     => 'label for the element',
   'required'  => 'whether element is required',
   'error'     => 'error associated with the element',
   'style'     => 'some information about element style (e.g. for Smarty)',
   'field'	   => 'field definition array for the associated field',
   // if element is not a group
   'html'      => 'HTML for the element'
   // if element is a group
   'separator' => 'separator for group elements',
   'elements'  => array(
     element_1,
     ...
     element_N
   )
 );
 *}
 
{literal}
<script language="javascript" type="text/javascript"><!--
	function Dataface_QuickForm(){
		
	}
	Dataface_QuickForm.prototype.setFocus = function(element_name){
		document.{/literal}{$form_data.name}{literal}.elements[element_name].focus();
		document.{/literal}{$form_data.name}{literal}.elements[element_name].select();
	}
	var quickForm = new Dataface_QuickForm();
//--></script>
{/literal}
		
<form{$form_data.attributes}>
{$form_data.hidden}
{$form_data.javascript}
 
{*
	#01 - Outer sections loop
	-------------------------
	We begin by going through each section of the form individually.
*}
<table width="100%" class="Dataface_QuickForm-table-wrapper Dataface_FindForm-table-wrapper">

{foreach from=$form_data.elements item=element}
	{*
		#04 - Render Element
		------------------------------
		This section is used to render an element to be displayed.
	*}
	{block name="findform_before_`$element.field.name`_row"}
	{define_slot name="findform_`$element.field.name`_row"}
	<tr id="{$element.field.name}_findform_row">
		<td valign="top" align="right" class="Dataface_QuickForm-label-cell Dataface_FindForm-label-cell {$element.field.tablename}">
		<div class="field" id="findform_{$element.field.tablename}-{$element.field.name}-label-wrapper">
		
			<label>{$element.field.widget.label}</label>
		
		</div>
		</td>
		<td class="Dataface_QuickForm-widget-cell Dataface_FindForm-widget-cell {$element.field.tablename}">
		<div class="field" id="{$element.field.tablename}-{$element.field.name}-wrapper">
		
		
		
		
			<div>
			
			{define_slot name="findform_`$element.field.name`_widget"}
			{block name="findform_before_`$element.field.name`_widget"}
			{if $element.html}
				{$element.html}
			{elseif $element.elements}
				<!--<fieldset><legend>{$element.field.widget.label}</legend>-->
				{if $element.field.widget.columns}{assign var=cols value=$element.field.widget.columns}{else}{assign var=cols value=3}{/if}
				{if $cols > 1}{*The user has specified columns to use so we place the grouped elements in a table.*}
					{assign var=numelements value=$element.elements|@count}
					{assign var=threshold value=$numelements/$cols}
					<table><tr><td>
				{/if}
				{assign var=ctr value=0}
				{foreach from=$element.elements item=groupel name=grouploop}
				
					{$groupel.html}{if $element.widget.separator}{$element.widget.separator}{else}{$element.separator}{/if}
					{assign var=ctr value=$ctr+1}
					{if ($cols > 1) and ($ctr >= $threshold)}</td><td>{assign var=ctr value=0}{/if}
				{/foreach}
				{if $cols > 1}
					</td></tr></table>
				{/if}
				<!--</fieldset>--> 
			{/if}
			{block name="findform_after_`$element.field.name`_widget"}
			{/define_slot}
			
			
			
			</div>
			<div class="formHelp">{$element.field.widget.description}</div>
			
			{if $element.field.widget.focus}
			<script language="javascript" type="text/javascript"><!--
			try{literal}{{/literal}quickForm.setFocus('{$element.field.name}');{literal}} catch(err){}{/literal}
			//--></script>
			
			
			{/if}
		</div>
		</td>
	</tr>
	{/define_slot}
	{block name="findform_after_`$element.field.name`_row"}

{/foreach}
</table>
{foreach from=$form_data.sections item=section}


	{*
		#02 - Scriptaculous collapsible sidebar
		---------------------------------------
	 	Let's use a scriptaculous collapsible sidebar for each section
	 	so that we have that cool animation effect it the user wants to
	 	hide a section.
	*}
	
	{collapsible_sidebar heading=$section.header}
	{block name="before_findform_table"}
		<table width="100%" class="Dataface_QuickForm-table-wrapper Dataface_FindForm-table-wrapper">
		
			{* 
				#03 - Inner elements loop
				--------------------------
				Now we go through each element in this section and render
				it.
			*}
			{foreach from=$section.elements item=element}
			
				{*
					#04 - Render Element
					------------------------------
					This section is used to render an element to be displayed.
				*}
				
				{block name="findform_before_`$element.field.name`_row"}
				{define_slot name="findform_`$element.field.name`_row"}
				<tr id="{$element.field.name}_findform_row">
					<td valign="top" align="right" class="Dataface_QuickForm-label-cell Dataface_FindForm-label-cell {$element.field.tablename}">
					<div class="field" id="findform_{$element.field.tablename}-{$element.field.name}-label-wrapper">
					
						<label>{$element.field.widget.label}</label>
					
					</div>
					</td>
					<td class="Dataface_QuickForm-widget-cell Dataface_FindForm-widget-cell {$element.field.tablename}">
					<div class="field" id="{$element.field.tablename}-{$element.field.name}-wrapper">
					
					
					
					
						<div>
						
						{define_slot name="findform_`$element.field.name`_widget"}
						{block name="findform_before_`$element.field.name`_widget"}
						{if $element.html}
							{$element.html}
						{elseif $element.elements}
							<!--<fieldset><legend>{$element.field.widget.label}</legend>-->
							{if $element.field.widget.columns}{assign var=cols value=$element.field.widget.columns}{else}{assign var=cols value=3}{/if}
							{if $cols > 1}{*The user has specified columns to use so we place the grouped elements in a table.*}
								{assign var=numelements value=$element.elements|@count}
								{assign var=threshold value=$numelements/$cols}
								<table><tr><td>
							{/if}
							{assign var=ctr value=0}
							{foreach from=$element.elements item=groupel name=grouploop}
							
								{$groupel.html}{if $element.widget.separator}{$element.widget.separator}{else}{$element.separator}{/if}
								{assign var=ctr value=$ctr+1}
								{if ($cols > 1) and ($ctr >= $threshold)}</td><td>{assign var=ctr value=0}{/if}
							{/foreach}
							{if $cols > 1}
								</td></tr></table>
							{/if}
							<!--</fieldset>--> 
						{/if}
						{block name="findform_after_`$element.field.name`_widget"}
						{/define_slot}
						
						
						
						</div>
						<div class="formHelp">{$element.field.widget.description}</div>
						
						{if $element.field.widget.focus}
						<script language="javascript" type="text/javascript"><!--
						try{literal}{{/literal}quickForm.setFocus('{$element.field.name}');{literal}} catch(err){}{/literal}
						//--></script>
						
						
						{/if}
					</div>
					</td>
				</tr>
				{/define_slot}
				{block name="findform_after_`$element.field.name`_row"}
			{/foreach}
		</table>
		{block name="after_findform_table"}
	{/collapsible_sidebar}
{/foreach}

</form>