-
Notifications
You must be signed in to change notification settings - Fork 45
/
fieldset.phtml
102 lines (94 loc) · 3.38 KB
/
fieldset.phtml
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
<div>
<a href="<?php echo $this->url('fileupload')?>">« Back to Examples Listing</a>
</div>
<h2><?php echo ($this->title) ?: 'File Upload Examples' ?></h2>
<?php
// Init Form
$form = $this->form;
$form->setAttribute('class', 'form-horizontal');
$form->prepare();
// Configure Errors Helper
$errorsHelper = $this->plugin('formelementerrors');
$errorsHelper
->setMessageOpenFormat('<div class="help-block">')
->setMessageSeparatorString('</div><div class="help-block">')
->setMessageCloseString('</div>');
?>
<?php echo $this->form()->openTag($form); ?>
<fieldset>
<legend><?php echo ($this->legend) ?: 'Single File Upload' ?></legend>
<?php
$elem = $form->get('fieldset')->get('text');
$elem->setLabelAttributes(array('class' => 'control-label'));
$errors = $elem->getMessages();
$errorClass = (!empty($errors)) ? ' error' : '';
?>
<div class="control-group<?php echo $errorClass ?>">
<?php echo $this->formLabel($elem); ?>
<div class="controls">
<?php echo $this->formText($elem); ?>
<?php echo $errorsHelper($elem); ?>
</div>
</div>
<?php
$elem = $form->get('fieldset')->get('file');
$elem->setLabelAttributes(array('class' => 'control-label'));
$errors = $elem->getMessages();
$errorClass = (!empty($errors)) ? ' error' : '';
?>
<div class="control-group<?php echo $errorClass ?>">
<?php echo $this->formLabel($elem); ?>
<div class="controls">
<?php echo $this->formFile($elem); ?>
<?php echo $errorsHelper($elem); ?>
<?php if (!empty($this->tempFiles['file'])) { ?>
<!--
Note: You might not want to render the file input in this
case either, depending on your use-case.
-->
<div class="help-block">
Uploaded: <ul>
<?php foreach ($this->tempFiles['file'] as $tempFile) { ?>
<li><?php echo $this->escapeHtml($tempFile['name']) ?></li>
<?php } ?>
</ul>
</div>
<?php } ?>
</div>
</div>
</fieldset>
<fieldset>
<legend>Not-nested Elements</legend>
<?php
$elem = $form->get('file2');
$elem->setLabelAttributes(array('class' => 'control-label'));
$errors = $elem->getMessages();
$errorClass = (!empty($errors)) ? ' error' : '';
?>
<div class="control-group<?php echo $errorClass ?>">
<?php echo $this->formLabel($elem); ?>
<div class="controls">
<?php echo $this->formFile($elem); ?>
<?php echo $errorsHelper($elem); ?>
<?php if (!empty($this->tempFiles['file2'])) { ?>
<!--
Note: You might not want to render the file input in this
case either, depending on your use-case.
-->
<div class="help-block">
Uploaded: <ul>
<?php foreach ($this->tempFiles['file2'] as $tempFile) { ?>
<li><?php echo $this->escapeHtml($tempFile['name']) ?></li>
<?php } ?>
</ul>
</div>
<?php } ?>
</div>
</div>
<div class="control-group">
<div class="controls">
<button class="btn btn-primary">Submit</button>
</div>
</div>
</fieldset>
<?php echo $this->form()->closeTag($form); ?>