Skip to content

Instantly share code, notes, and snippets.

@jedateach
Created April 23, 2014 22:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jedateach/11235416 to your computer and use it in GitHub Desktop.
Save jedateach/11235416 to your computer and use it in GitHub Desktop.
Silverstripe non-associative array config
<?php
public function getRequiredFields() {
$fields = self::config()->required_fields;
//hack to allow overriding arrays in ss config
if(self::$required_fields != $fields){
foreach(self::$required_fields as $requirement){
if(($key = array_search($requirement, $fields)) !== false) {
unset($fields[$key]);
}
}
}
$this->extend('updateRequiredFields', $fields);
return $fields;
}
@jedateach
Copy link
Author

Another solution could be to use a seperate array for overriding values

if($f = self::config()->custom_required_fields){
   $fields = $f;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment