Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

Commit

Permalink
Merge pull request #1644 from njam/form-viewResponse
Browse files Browse the repository at this point in the history
Breaking: Change signature of Form::prepare()
  • Loading branch information
njam committed Feb 18, 2015
2 parents f272e7d + 56d895e commit a8b1d34
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
7 changes: 7 additions & 0 deletions library/CM/Form/Abstract.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ var CM_Form_Abstract = CM_View_Abstract.extend({
return this._fields[name];
},

/**
* @return Boolean
*/
hasField: function(name) {
return !!this._fields[name];
},

/**
* @return jQuery
*/
Expand Down
2 changes: 1 addition & 1 deletion library/CM/Form/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function __construct($params = null) {
$this->_initialize();
}

public function prepare(CM_Frontend_Environment $environment) {
public function prepare(CM_Frontend_Environment $environment, CM_Frontend_ViewResponse $viewResponse) {
}

/**
Expand Down
2 changes: 1 addition & 1 deletion library/CM/Form/Example.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ protected function _initialize() {
$this->registerAction(new CM_FormAction_Example_Go($this));
}

public function prepare(CM_Frontend_Environment $environment) {
public function prepare(CM_Frontend_Environment $environment, CM_Frontend_ViewResponse $viewResponse) {
if (CM_Http_Request_Abstract::hasInstance()) {
$ip = CM_Http_Request_Abstract::getInstance()->getIp();
if ($locationGuess = CM_Model_Location::findByIp($ip)) {
Expand Down
2 changes: 1 addition & 1 deletion library/CM/Form/ExampleIcon.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ protected function _initialize() {
$this->registerField(new CM_FormField_Integer(['name' => 'shadowBlur', 'min' => 0, 'max' => 20]));
}

public function prepare(CM_Frontend_Environment $environment) {
public function prepare(CM_Frontend_Environment $environment, CM_Frontend_ViewResponse $viewResponse) {
$this->getField('sizeSlider')->setValue(18);
$this->getField('shadowColor')->setValue('#333');
$this->getField('colorBackground')->setValue('#fafafa');
Expand Down
4 changes: 2 additions & 2 deletions library/CM/SmartyPlugins/block.form.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ function smarty_block_form($params, $content, Smarty_Internal_Template $template
$frontend = $render->getGlobalResponse();
if ($open) {
$form = CM_Form_Abstract::factory($params['name'], $params);
$form->prepare($render->getEnvironment());

$viewResponse = new CM_Frontend_ViewResponse($form);
$form->prepare($render->getEnvironment(), $viewResponse);

$frontend->treeExpand($viewResponse);
return '';
} else {
Expand Down

0 comments on commit a8b1d34

Please sign in to comment.