Values for defaults variable of a module can also be set in mysite/_config.php. This allows for modification of the defaults without having to change anything in the module folder, which will make upgrading easier. For example you can change the default way Blog Entry posts are shown in the menus with the code below.
BlogEntry::$defaults['ShowInMenus'] = true;
Unfortunately this doesn't work for setting default sort order for a DataObject. If you add the following to your _config.php
Country::$default_sort = 'Name';
you will get an error like:
[User Error] Couldn't run query: SELECT ... ORDER BY "Name" Unknown column 'Name' in 'order clause'
Line 525 in G:\localhost\lhnet.org\sapphire\core\model\MySQLDatabase.php
The sort order seems to be set for all types of DataObject defined. The solution, add the sort order to your DataObject definition:
class Country extends DataObject {
static $default_sort = 'Name';
::
Following http://doc.silverstripe.org/sapphire/en/reference/member
/**
* Returns a valid {@link ValidationResult} if this member can currently log in, or an invalid
* one with error messages to display if the member is locked out.
*
* You can hook into this with a "canLogIn" method on an attached extension.
*
* @return ValidationResult
*/
public function canLogIn() {
Can be used in extends DataObjectDecorator as:
function canLogIn(&$result) {
// Do something
// using: $this->owner->Variable
return $result;
}