Hi all,
I'm working on a very stripped down version of BlackCandy on 2.3.3 to be used as a starting point for new projects. I have noticed a few things I don't think I have noticed before, and was wondering if someone could clear them up:
1. I see Prototype is included by default in any page. I thought this was stopped in favour of jQuery in 2.3.0? Yes I know how to block it, but I was curious as to the future of Prototype with SS.
2. When I include $SearchForm in my template, the following code is injected at the bottom of the source:
Behaviour.register({
'#SearchForm_SearchForm': {
validate : function(fromAnOnBlur) {
initialiseForm(this, fromAnOnBlur);
var error = hasHadFormError();
if(!error && fromAnOnBlur) clearErrorMessage(fromAnOnBlur);
return !error;
},
onsubmit : function() {
if(typeof this.bypassValidation == 'undefined' || !this.bypassValidation) return this.validate();
}
},
'#SearchForm_SearchForm input' : {
initialise: function() {
if(!this.old_onblur) this.old_onblur = function() { return true; }
if(!this.old_onfocus) this.old_onfocus = function() { return true; }
},
onblur : function() {
if(this.old_onblur()) {
// Don't perform instant validation for CalendarDateField fields; it creates usability wierdness.
if(this.parentNode.className.indexOf('calendardate') == -1 || this.value) {
return $('SearchForm_SearchForm').validate(this);
} else {
return true;
}
}
}
},
'#SearchForm_SearchForm select' : {
initialise: function() {
if(!this.old_onblur) this.old_onblur = function() { return true; }
},
onblur : function() {
if(this.old_onblur()) {
return $('SearchForm_SearchForm').validate(this);
}
}
}
});
//]]>
Why is this included? The SearchForm method on Page.php is as follows:
function SearchForm() {
$searchText = isset($_REQUEST['Search']) ? $_REQUEST['Search'] : 'Search';
$fields = new FieldSet(
new TextField("Search", "", $searchText)
);
$actions = new FieldSet(
new FormAction('results', 'Search')
);
return new SearchForm($this, "SearchForm", $fields, $actions);
}
3. A quick look at the source for Silverstripe.org shows that neither prototype is included, nor is the above JS block injected, despite the search form seemingly being exactly the same.
Ta
Aaron