silverstrap 

silverstrap Commit Details

Date:2013-06-16 18:28:38 (6 years 3 months ago)
Author:Nicola Fontana
Branch:bootstrap2, dev, master, master-1.0, ss3
Commit:b54133f1c52b597cc467e67f797b611dd89b6281
Parents: 5894accc22e4e9303a2e1ad61207592506e04282
Message:Added basic support for form rendering

The default templates provided by SilverStripe are totally differents
from the approach taken by Bootstrap.

Implemented a subset of fields in a Bootstrap compatible way (for as
much as possible): rendering and PHP are not properly decoupled (e.g.
extraClasses is supposed to be appied to <input> but I found no way to
apply custom classes to the <div> holder).
Changes:
Atemplates/forms/CGClosing.ss (full)
Atemplates/forms/CGOpening.ss (full)
Atemplates/forms/CheckboxField_holder.ss (full)
Atemplates/forms/CompositeField.ss (full)
Atemplates/forms/CompositeField_holder.ss (full)
Atemplates/forms/FieldGroup_holder.ss (full)
Atemplates/forms/Form.ss (full)
Atemplates/forms/FormAction.ss (full)
Atemplates/forms/FormField.ss (full)
Atemplates/forms/FormField_holder.ss (full)
Mcss/silverstrap.css (2 diffs)

File differences

css/silverstrap.css
55
66
77
8
89
910
1011
1112
13
1214
1315
1416
......
1618
1719
1820
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
21
13722
13823
139
24
25
14026
14127
14228
position: relative;
top: -40px;
}
/* Match margin-bottom to margin-top */
#content {
margin-top: 20px;
margin-bottom: 20px;
}
/* Nested sublevel grouping, not used in these templates */
.nav {
margin-top: 20px;
padding-left: 15px;
}
.nav .nav {
margin-top: 0;
margin-bottom: 8px;
}
form {
margin-top: 3ex;
}
form label.left {
float: left;
clear: left;
width: 20%;
}
form .middleColumn {
float: left;
padding-right: 1em;
}
form div.checkbox {
clear: left;
margin-left: 20%;
}
form #Privacy {
clear: left;
margin-left: 20%;
height: 16ex;
overflow: auto;
border: 1px solid #dad9d9;
padding: 4px;
}
form #Privacy h4 {
margin-top: 0;
}
form #Accept {
clear: left;
margin: 1ex 0 2ex 20%;
}
form div.Actions {
clear: left;
margin-left: 20%;
}
span.message {
float: left;
padding-bottom: 2ex;
color: #F00;
}
p.message {
padding: 8px;
color: #080;
background-color: #8F8;
border: 1px solid #080;
}
p.bad {
color: #F00;
background-color: #F88;
border: 1px solid #F00;
}
span.message,
p.message {
font-style: italic;
font-weight: bolder;
}
/* Image handling, borrowed from Simple */
img {
border: none;
height: auto;
}
img.left {
float: left;
max-width: 50%;
margin: 5px 20px 10px 0;
}
img.right {
float: right;
max-width: 50%;
margin: 5px 0 10px 20px;
}
img.leftAlone {
float: left;
margin-right: 100%;
margin-bottom: 10px;
clear: both;
}
img.center {
float: none;
margin-left: auto;
margin-right: auto;
display: block;
margin-bottom: 10px;
clear: both;
}
.captionImage {
width: 100%;
margin: 5px 0px 20px 0px;
}
.captionImage.left {
float: left;
margin-right: 20px;
}
.captionImage.leftAlone{
float: none;
margin-right: 20px;
}
.captionImage.right{
float: right;
margin-left: 20px;
}
.captionImage.center{
margin-left: auto;
margin-right: auto;
}
.captionImage p {
clear: both;
margin: 5px 0;
font-style: italic;
color: #888;
}
.captionImage.right p {
margin-left: -10px;
text-align: left;
margin-left: -10px;
margin-bottom: 4px;
}
/* Zoomable images */
/* Zoomable images, especially added to be backward compatible with the
* silverstripe-treeish theme */
.zoom {
float: right;
clear: right;
templates/forms/CGClosing.ss
1
2
<% if $Message %><span class="help-block">$Message</span>
<% end_if %></div>
templates/forms/CGOpening.ss
1
<div class="control-group $HolderClasses<% if $Message %> error<% end_if %>">
templates/forms/CheckboxField_holder.ss
1
2
3
4
5
6
7
8
9
<%-- Override extraClass otherwise .checkbox would increase padding-left --%>
<% include CGOpening extraClass="" %>
<div class="controls">
<label class="checkbox">
$Field
$Title
</label>
</div>
<% include CGClosing %>
templates/forms/CompositeField.ss
1
2
3
4
5
6
7
<$Tag class="$extraClass"><% if $Tag == 'fieldset' && $Legend %>
<legend>$Legend</legend><% end_if %><% loop $FieldList %><% if $ColumnCount %>
<div class="column-{$ColumnCount} $FirstLast">
$Field
</div><% else %>
$Field<% end_if %><% end_loop %>
</$Tag>
templates/forms/CompositeField_holder.ss
1
2
3
4
5
6
7
<$Tag class="$extraClass<% if ColumnCount %> multicolumn<% end_if %>"><% if $Tag == 'fieldset' && $Legend %>
<legend>$Legend</legend><% end_if %><% loop $FieldList %><% if $ColumnCount %>
<div class="column-{$ColumnCount} $FirstLast">
$FieldHolder
</div><% else %>
$FieldHolder<% end_if %><% end_loop %>
</$Tag>
templates/forms/FieldGroup_holder.ss
1
2
3
4
5
6
7
<% include CGOpening %><% if $Title %>
<label class="control-label" for="$ID">$Title</label><% end_if %>
<div class="controls"><% loop $FieldList %>
$SmallFieldHolder<% end_loop %>
</div><% if $RightTitle %>
<label class="control-label" for="$ID">$RightTitle</label><% end_if %>
<% include CGClosing %>
templates/forms/Form.ss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<% if $IncludeFormTag %>
<form class="form-horizontal" $AttributesHTML><% end_if %><% if $Message %>
<div id="{$FormName}_error" class="alert $MessageType">
<button type="button" class="close" data-dismiss="alert">&times;</button>
$Message
</div><% else %>
<div id="{$FormName}_error" class="alert $MessageType" style="display: none"></div><% end_if %>
<fieldset><% if $Legend %>
<legend>$Legend</legend><% end_if %><% loop $Fields %>
$FieldHolder<% end_loop %>
</fieldset>
<div class="clearfix"></div><% if $Actions %>
<div class="control-group">
<div class="form-actions"><% loop $Actions %>
$Field<% end_loop %>
</div>
</div><% end_if %><% if $IncludeFormTag %>
</form><% end_if %>
templates/forms/FormAction.ss
1
2
3
4
<button class="btn<% if $Type=="action" %> btn-primary<% end_if %>" $AttributesHTML><% if $ButtonContent %>
$ButtonContent<% else %>
$Title<% end_if %>
</button>
templates/forms/FormField.ss
1
<input $AttributesHTML<% if $isReadonly %> disabled<% end_if %> />
templates/forms/FormField_holder.ss
1
2
3
4
5
6
7
<% include CGOpening %><% if $Title %>
<label class="control-label"<% if $ID %> for="$ID"<% end_if %>>$Title</label><% end_if %>
<div class="controls">
$Field
</div><% if $RightTitle %>
<label class="control-label" for="$ID">$RightTitle</label><% end_if %>
<% include CGClosing %>

Archive Download the corresponding diff file