Skip to content

Instantly share code, notes, and snippets.

@robwilkerson
Created November 2, 2011 16:52
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 robwilkerson/1334191 to your computer and use it in GitHub Desktop.
Save robwilkerson/1334191 to your computer and use it in GitHub Desktop.
CakePHP: Creating a white list dynamically.
/**
* Model constructor.
*/
public function __construct( $id = false, $table = null, $ds = null ) {
parent::__construct( $id, $table, $ds );
# Generate a whitelist that doesn't require me to make an update every time
# I add a property...unless I don't want that property to be batch updated.
# For me, this is usually the exception rather than the rule.
$this->whitelist = array_diff( array_keys( $this->schema() ), array( 'id', 'admin', 'last_login', 'active', 'created', 'modified' ) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment