Skip to content
Permalink
Browse files

Fix issue with inputs() and plugin models.

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 78b23d8e31331d4890c2fdfb18cb663a33caba4c
Showing with 27 additions and 1 deletion.
  1. +25 −0 lib/Cake/Test/Case/View/Helper/FormHelperTest.php
  2. +2 −1 lib/Cake/View/Helper/FormHelper.php
@@ -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
*
@@ -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);
}

0 comments on commit 78b23d8

Please sign in to comment.
You can’t perform that action at this time.