@@ -17,6 +17,8 @@ class BootstrapFieldList extends Extension {
1717 public function bootstrapify () {
1818 foreach ($ this ->owner as $ f ) {
1919
20+ $ sng = Injector::inst ()->get ($ f ->class , true , ['dummy ' , '' ]);
21+
2022 if (isset ($ this ->ignores [$ f ->getName ()])) continue ;
2123
2224 // If we have a Tabset, bootstrapify all Tabs
@@ -29,27 +31,34 @@ public function bootstrapify() {
2931 $ f ->Fields ()->bootstrapify ();
3032 }
3133
32- $ template = "Bootstrap {$ f ->class }_holder " ;
33- if (SSViewer::hasTemplate ($ template )) {
34- $ f ->setFieldHolderTemplate ($ template );
35- }
36- else {
37- $ f ->setFieldHolderTemplate ("BootstrapFieldHolder " );
38- }
39-
40- foreach (array_reverse (ClassInfo::ancestry ($ f )) as $ className ) {
41- $ bootstrapCandidate = "Bootstrap {$ className }" ;
42- $ nativeCandidate = $ className ;
43- if (SSViewer::hasTemplate ($ bootstrapCandidate )) {
44- $ f ->setTemplate ($ bootstrapCandidate );
45- break ;
34+ // If the user has customised the holder template already, don't apply the default one.
35+ if ($ sng ->getFieldHolderTemplate () == $ f ->getFieldHolderTemplate ()) {
36+ $ template = "Bootstrap {$ f ->class }_holder " ;
37+ if (SSViewer::hasTemplate ($ template )) {
38+ $ f ->setFieldHolderTemplate ($ template );
4639 }
47- elseif (SSViewer::hasTemplate ($ nativeCandidate )) {
48- $ f ->setTemplate ($ nativeCandidate );
49- break ;
40+ else {
41+ $ f ->setFieldHolderTemplate ("BootstrapFieldHolder " );
5042 }
5143
44+ }
45+
46+ // If the user has customised the field template already, don't apply the default one.
47+ if ($ sng ->getTemplate () == $ f ->getTemplate ()) {
48+ foreach (array_reverse (ClassInfo::ancestry ($ f )) as $ className ) {
49+ $ bootstrapCandidate = "Bootstrap {$ className }" ;
50+ $ nativeCandidate = $ className ;
51+ if (SSViewer::hasTemplate ($ bootstrapCandidate )) {
52+ $ f ->setTemplate ($ bootstrapCandidate );
53+ break ;
54+ }
55+ elseif (SSViewer::hasTemplate ($ nativeCandidate )) {
56+ $ f ->setTemplate ($ nativeCandidate );
57+ break ;
58+ }
5259
60+
61+ }
5362 }
5463 }
5564
@@ -67,4 +76,4 @@ public function bootstrapIgnore($field) {
6776
6877 return $ this ->owner ;
6978 }
70- }
79+ }
0 commit comments