Navigation Menu

Skip to content

Commit

Permalink
Fix issue with inputs() and plugin models.
Browse files Browse the repository at this point in the history
inputs() should not trigger errors when generating inputs for plugin
models. Previously the internal state of FormHelper was incorrect as
model() returned the plugin name instead of the modelname.

Fixes #3571
  • Loading branch information
markstory committed Jan 30, 2013
1 parent 4109812 commit 78b23d8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
25 changes: 25 additions & 0 deletions lib/Cake/Test/Case/View/Helper/FormHelperTest.php
Expand Up @@ -2996,6 +2996,31 @@ public function testFormInputs() {
$this->assertTags($result, $expected);
}

/**
* Tests inputs() works with plugin models
*
* @return void
*/
public function testInputsPluginModel() {
$this->loadFixtures('Post');
App::build(array(
'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS)
));
CakePlugin::load('TestPlugin');
$this->Form->request['models'] = array(
'TestPluginPost' => array('plugin' => 'TestPlugin', 'className' => 'TestPluginPost')
);
$this->Form->create('TestPlugin.TestPluginPost');
$result = $this->Form->inputs();

$this->assertContains('data[TestPluginPost][id]', $result);
$this->assertContains('data[TestPluginPost][author_id]', $result);
$this->assertContains('data[TestPluginPost][title]', $result);
$this->assertTrue(ClassRegistry::isKeySet('TestPluginPost'));
$this->assertFalse(ClassRegistry::isKeySet('TestPlugin'));
$this->assertEquals('TestPluginPost', $this->Form->model());
}

/**
* testSelectAsCheckbox method
*
Expand Down
3 changes: 2 additions & 1 deletion lib/Cake/View/Helper/FormHelper.php
Expand Up @@ -329,7 +329,8 @@ public function create($model = null, $options = array()) {

$key = null;
if ($model !== false) {
$key = $this->_introspectModel($model, 'key');
list($plugin, $model) = pluginSplit($model, true);
$key = $this->_introspectModel($plugin . $model, 'key');
$this->setEntity($model, true);
}

Expand Down

0 comments on commit 78b23d8

Please sign in to comment.