Skip to content

Commit

Permalink
API Refactor for removal of CMSForm class
Browse files Browse the repository at this point in the history
  • Loading branch information
Damian Mooyman committed Mar 7, 2016
1 parent 7597ed6 commit 02343a0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ before_script:
- composer self-update || true
- git clone git://github.com/silverstripe-labs/silverstripe-travis-support.git ~/travis-support
- "if [ \"$BEHAT_TEST\" = \"\" ]; then php ~/travis-support/travis_setup.php --source `pwd` --target ~/builds/ss; fi"
- "if [ \"$BEHAT_TEST\" = \"1\" ]; then php ~/travis-support/travis_setup.php --source `pwd` --target ~/builds/ss --require silverstripe/behat-extension,silverstripe/cms; fi"
- "if [ \"$BEHAT_TEST\" = \"1\" ]; then php ~/travis-support/travis_setup.php --source `pwd` --target ~/builds/ss --require silverstripe/behat-extension:~2,silverstripe/cms; fi"
- cd ~/builds/ss
- php ~/travis-support/travis_setup_selenium.php --if-env BEHAT_TEST
- php ~/travis-support/travis_setup_php54_webserver.php --if-env BEHAT_TEST
Expand Down
18 changes: 16 additions & 2 deletions code/controller/SiteConfigLeftAndMain.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,24 @@ public function getEditForm($id = null, $fields = null)
}

$actions = $siteConfig->getCMSActions();
$form = CMSForm::create(
$negotiator = $this->getResponseNegotiator();
/** @var Form $form */
$form = Form::create(
$this, 'EditForm', $fields, $actions, $validator
)->setHTMLID('Form_EditForm');
$form->setResponseNegotiator($this->getResponseNegotiator());
$form->setValidationResponseCallback(function() use ($negotiator, $form) {
$request = $this->getRequest();
if($request->isAjax() && $negotiator) {
$form->setupFormErrors();
$result = $form->forTemplate();

return $negotiator->respond($request, array(
'CurrentForm' => function() use($result) {
return $result;
}
));
}
});
$form->addExtraClass('cms-content center cms-edit-form');
$form->setAttribute('data-pjax-fragment', 'CurrentForm');

Expand Down

0 comments on commit 02343a0

Please sign in to comment.