Skip to content

Commit

Permalink
Fixing issue when generating textarea with null value.
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8146 3807eeeb-6ff5-0310-8944-8be069107fe0
  • Loading branch information
renan committed Apr 16, 2009
1 parent 8db4fe6 commit bd7bd5d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cake/libs/view/helper.php
Expand Up @@ -591,7 +591,7 @@ function value($options = array(), $field = null, $key = 'value') {

if (is_array($result)) {
$view =& ClassRegistry::getObject('view');
if (isset($result[$view->fieldSuffix])) {
if (array_key_exists($view->fieldSuffix, $result)) {
$result = $result[$view->fieldSuffix];
}
}
Expand Down
16 changes: 12 additions & 4 deletions cake/tests/cases/libs/view/helpers/form.test.php
Expand Up @@ -2553,8 +2553,8 @@ function testRadio() {
'/label'
);
$this->assertTags($result, $expected);


$result = $this->Form->radio('Model.field', array('option A', 'option B'), array('name' => 'data[Model][custom]'));
$expected = array(
'fieldset' => array(),
Expand Down Expand Up @@ -4247,6 +4247,14 @@ function testTextArea() {
'/textarea',
);
$this->assertTags($result, $expected);

$this->Form->data['Model']['0']['OtherModel']['field'] = null;
$result = $this->Form->textarea('Model.0.OtherModel.field');
$expected = array(
'textarea' => array('name' => 'data[Model][0][OtherModel][field]', 'id' => 'Model0OtherModelField'),
'/textarea'
);
$this->assertTags($result, $expected);
}
/**
* testTextAreaWithStupidCharacters method
Expand Down Expand Up @@ -4564,8 +4572,8 @@ function testFormCreateQuerystringParams() {
));
$expected = array(
'form' => array(
'id' => 'ContactAddForm',
'method' => 'post',
'id' => 'ContactAddForm',
'method' => 'post',
'action' => '/controller/action/?param1=value1&param2=value2'
),
'fieldset' => array('style' => 'preg:/display\s*\:\s*none;\s*/'),
Expand Down

0 comments on commit bd7bd5d

Please sign in to comment.