Skip to content

Instantly share code, notes, and snippets.

@muskie9
Created March 10, 2016 17:40
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 muskie9/146a2161fbc6ee66f64e to your computer and use it in GitHub Desktop.
Save muskie9/146a2161fbc6ee66f64e to your computer and use it in GitHub Desktop.
<?php
/**
* assume $data['ID'] is an integer
*
* when the object is queried, it has the correct data.
* using both the method shown and $form->saveInto($school);
* the write() creates a new object rather than update the queried object
*
* @param $data
* @param $form
* @throws ValidationException
* @throws null
*/
public function doEditSchool($data, $form)
{
if($school = School::get()->byID($data['ID'])){
$school->Title = $data['Title'];
$school->Active = $data['Active'];
$school->write();
}
$this->redirect(MemberManagementPage::get()->first()->Link('schools'));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment