Skip to content

Commit

Permalink
Removing empty strings that caused undefined string offset errors.
Browse files Browse the repository at this point in the history
Trimming trailing spaces.
  • Loading branch information
markstory committed Oct 22, 2009
1 parent 2f0598b commit 6123ed4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
24 changes: 12 additions & 12 deletions cake/libs/view/helpers/form.php
Expand Up @@ -71,9 +71,9 @@ class FormHelper extends AppHelper {
* @access public
*/
var $requestType = null;

var $defaultModel = null;

function &_introspectModel($model) {
$object = null;
if (is_string($model) && strpos($model, '.') !== false) {
Expand Down Expand Up @@ -118,7 +118,7 @@ function &_introspectModel($model) {
$key = $object->primaryKey;
$this->fieldset[$object->name] = array_merge($defaults,compact('fields', 'key', 'validates'));
}

return $object;
}

Expand All @@ -140,7 +140,7 @@ function &_introspectModel($model) {
* - 'url' The url the form submits to. Can be a string or a url array,
* - 'default' Allows for the creation of Ajax forms.
* - 'onsubmit' Used in conjunction with 'default' to create ajax forms.
* - 'inputDefaults' set the default $options for FormHelper::input(). Any options that would
* - 'inputDefaults' set the default $options for FormHelper::input(). Any options that would
* be set when using FormHelper::input() can be set here. Options set with `inputDefaults`
* can be overridden when calling input()
*
Expand All @@ -163,7 +163,7 @@ function create($model = null, $options = array()) {
} elseif (empty($model) && empty($this->params['models'])) {
$model = false;
}

$models = ClassRegistry::keys();
foreach ($models as $currentModel) {
if (ClassRegistry::isKeySet($currentModel)) {
Expand All @@ -176,15 +176,15 @@ function create($model = null, $options = array()) {

$object =& $this->_introspectModel($model);
$this->setEntity($model . '.', true);

if (isset($this->fieldset[$this->model()]['key'])) {
$data = $this->fieldset[$this->model()];
$recordExists = (
isset($this->data[$model]) &&
isset($this->data[$model][$data['key']]) &&
!empty($this->data[$model][$data['key']])
);

if ($recordExists) {
$created = true;
$id = $this->data[$model][$data['key']];
Expand Down Expand Up @@ -517,10 +517,10 @@ function label($fieldName = null, $text = null, $options = array()) {
* will be used.
*
* In addition to controller fields output, `$fields` can be used to control legend
* and fieldset rendering with the `fieldset` and `legend` keys.
* `$form->inputs(array('legend' => 'My legend'));` Would generate an input set with
* and fieldset rendering with the `fieldset` and `legend` keys.
* `$form->inputs(array('legend' => 'My legend'));` Would generate an input set with
* a custom legend. You can customize individual inputs through `$fields` as well.
*
*
* {{{
* $form->inputs(array(
* 'name' => array('label' => 'custom label')
Expand Down Expand Up @@ -634,7 +634,7 @@ function input($fieldName, $options = array()) {
);
$defaults = array('before' => null, 'between' => null, 'after' => null);
$options = array_merge($defaults, $options);

if (!isset($this->fieldset[$this->model()])) {
//Try to load fieldset for this model
$this->_introspectModel($this->model());
Expand Down Expand Up @@ -1119,7 +1119,7 @@ function file($fieldName, $options = array()) {
*
* Options:
*
* - `escape` - HTML entity encode the $title of the button. Defaults to false.
* - `escape` - HTML entity encode the $title of the button. Defaults to false.
*
* @param string $title The button's caption. Not automatically HTML encoded
* @param array $options Array of options and HTML attributes.
Expand Down
2 changes: 1 addition & 1 deletion cake/libs/view/view.php
Expand Up @@ -614,7 +614,7 @@ function entity() {
$count = count($path);
if (
($count == 1 && !empty($this->association)) ||
($count == 1 && $this->model != $this->entityPath) ||
($count == 1 && $this->model != $this->entityPath) ||
($count == 2 && !empty($this->fieldSuffix)) ||
is_numeric($path[0])
) {
Expand Down
8 changes: 4 additions & 4 deletions cake/tests/cases/libs/view/helpers/form.test.php
Expand Up @@ -5477,7 +5477,7 @@ function testBrokenness() {
);
$this->assertTags($result, $expected);
}

function testMultiRecordForm() {
$this->Form->create('ValidateProfile');
$this->Form->data['ValidateProfile'][1]['ValidateItem'][2]['name'] = 'Value';
Expand Down Expand Up @@ -5510,23 +5510,23 @@ function testMultiRecordForm() {
'id' => 'ValidateProfile1ValidateItem2CreatedMonth'
)
),
array('option' => array('value' => '')), '', '/option',
array('option' => array('value' => '')), '/option',
$this->dateRegex['monthsRegex'],
'/select', '-',
array('select' => array(
'name' => 'data[ValidateProfile][1][ValidateItem][2][created][day]',
'id' => 'ValidateProfile1ValidateItem2CreatedDay'
)
),
array('option' => array('value' => '')), '', '/option',
array('option' => array('value' => '')), '/option',
$this->dateRegex['daysRegex'],
'/select', '-',
array('select' => array(
'name' => 'data[ValidateProfile][1][ValidateItem][2][created][year]',
'id' => 'ValidateProfile1ValidateItem2CreatedYear'
)
),
array('option' => array('value' => '')), '', '/option',
array('option' => array('value' => '')), '/option',
$this->dateRegex['yearsRegex'],
'/select',
'/div'
Expand Down

0 comments on commit 6123ed4

Please sign in to comment.