diff --git a/cake/console/templates/default/views/form.ctp b/cake/console/templates/default/views/form.ctp index ce2b525f9..b466611d3 100644 --- a/cake/console/templates/default/views/form.ctp +++ b/cake/console/templates/default/views/form.ctp @@ -19,7 +19,7 @@
Form->create('{$modelClass}');?>\n";?>
- ", Inflector::humanize($action), $singularHumanName); ?> + ", Inflector::humanize($action), $singularHumanName); ?> init($config)) { - if (time() % self::$_engines[$name]->settings['probability'] === 0) { + if (self::$_engines[$name]->settings['probability'] && time() % self::$_engines[$name]->settings['probability'] === 0) { self::$_engines[$name]->gc(); } return true; diff --git a/cake/libs/cake_log.php b/cake/libs/cake_log.php index e632c2898..53b29af93 100644 --- a/cake/libs/cake_log.php +++ b/cake/libs/cake_log.php @@ -219,4 +219,4 @@ class CakeLog { } return true; } -} +} \ No newline at end of file diff --git a/cake/libs/cake_socket.php b/cake/libs/cake_socket.php index 82610ff92..2a07a387a 100644 --- a/cake/libs/cake_socket.php +++ b/cake/libs/cake_socket.php @@ -117,7 +117,7 @@ class CakeSocket { } if (!empty($errNum) || !empty($errStr)) { - $this->setLastError($errStr, $errNum); + $this->setLastError($errNum, $errStr); throw new SocketException($errStr, $errNum); } diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/form.php index 74c0e2f38..d8f11c877 100644 --- a/cake/libs/view/helpers/form.php +++ b/cake/libs/view/helpers/form.php @@ -364,10 +364,6 @@ class FormHelper extends AppHelper { unset($options['label']); } $submitOptions = $options; - - if (!$submit) { - $submit = __('Submit'); - } } $out .= $this->submit($submit, $submitOptions); } @@ -1364,7 +1360,7 @@ class FormHelper extends AppHelper { * @link http://book.cakephp.org/view/1431/submit */ public function submit($caption = null, $options = array()) { - if (!$caption) { + if (!is_string($caption) && empty($caption)) { $caption = __('Submit'); } $out = null; @@ -1469,7 +1465,7 @@ class FormHelper extends AppHelper { $style = null; $tag = null; $attributes += array( - 'class' => null, + 'class' => null, 'escape' => true, 'secure' => null, 'empty' => '', @@ -2090,6 +2086,8 @@ class FormHelper extends AppHelper { if (empty($attributes['class'])) { $attributes['class'] = 'checkbox'; + } elseif ($attributes['class'] === 'form-error') { + $attributes['class'] = 'checkbox ' . $attributes['class']; } $label = $this->label(null, $title, $label); $item = $this->Html->useTag('checkboxmultiple', $name, $htmlOptions); @@ -2224,7 +2222,7 @@ class FormHelper extends AppHelper { } else { $secure = (isset($this->request['_Token']) && !empty($this->request['_Token'])); } - + $fieldName = null; if ($secure && !empty($options['name'])) { preg_match_all('/\[(.*?)\]/', $options['name'], $matches); diff --git a/cake/libs/view/helpers/js.php b/cake/libs/view/helpers/js.php index 172c67556..801d6a3cd 100644 --- a/cake/libs/view/helpers/js.php +++ b/cake/libs/view/helpers/js.php @@ -404,7 +404,10 @@ class JsHelper extends AppHelper { * @return array Array of js options and Htmloptions */ protected function _getHtmlOptions($options, $additional = array()) { - $htmlKeys = array_merge(array('class', 'id', 'escape', 'onblur', 'onfocus', 'rel', 'title'), $additional); + $htmlKeys = array_merge( + array('class', 'id', 'escape', 'onblur', 'onfocus', 'rel', 'title', 'style'), + $additional + ); $htmlOptions = array(); foreach ($htmlKeys as $key) { if (isset($options[$key])) { diff --git a/cake/tests/cases/libs/model/model_write.test.php b/cake/tests/cases/libs/model/model_write.test.php index 5e301cbc8..b9bdd8168 100644 --- a/cake/tests/cases/libs/model/model_write.test.php +++ b/cake/tests/cases/libs/model/model_write.test.php @@ -2972,7 +2972,8 @@ class ModelWriteTest extends BaseModelTest { 'published' => 'Y', 'user_id' => 1 )) - ), array('validate' => 'only')); + ), array('validate' => 'first')); + $this->assertFalse($result); } /** diff --git a/cake/tests/cases/libs/view/helpers/form.test.php b/cake/tests/cases/libs/view/helpers/form.test.php index 5ff9ae980..e5def54f1 100644 --- a/cake/tests/cases/libs/view/helpers/form.test.php +++ b/cake/tests/cases/libs/view/helpers/form.test.php @@ -3633,6 +3633,42 @@ class FormHelperTest extends CakeTestCase { 'label' => false )); $this->assertTags($result, $expected); + + $this->Form->validationErrors['Model']['tags'] = 'Select atleast one option'; + $result = $this->Form->input('Model.tags', array( + 'options' => array('one'), + 'multiple' => 'checkbox', + 'label' => false, + 'div' => false + )); + $expected = array( + 'input' => array('type' => 'hidden', 'name' => 'data[Model][tags]', 'value' => '', 'id' => 'ModelTags'), + array('div' => array('class' => 'checkbox form-error')), + array('input' => array('type' => 'checkbox', 'name' => 'data[Model][tags][]', 'value' => '0', 'id' => 'ModelTags0')), + array('label' => array('for' => 'ModelTags0')), + 'one', + '/label', + '/div' + ); + $this->assertTags($result, $expected); + + $result = $this->Form->input('Model.tags', array( + 'options' => array('one'), + 'multiple' => 'checkbox', + 'class' => 'mycheckbox', + 'label' => false, + 'div' => false + )); + $expected = array( + 'input' => array('type' => 'hidden', 'name' => 'data[Model][tags]', 'value' => '', 'id' => 'ModelTags'), + array('div' => array('class' => 'mycheckbox form-error')), + array('input' => array('type' => 'checkbox', 'name' => 'data[Model][tags][]', 'value' => '0', 'id' => 'ModelTags0')), + array('label' => array('for' => 'ModelTags0')), + 'one', + '/label', + '/div' + ); + $this->assertTags($result, $expected); } /** @@ -5367,6 +5403,14 @@ class FormHelperTest extends CakeTestCase { * @return void */ function testSubmitButton() { + $result = $this->Form->submit(''); + $expected = array( + 'div' => array('class' => 'submit'), + 'input' => array('type' => 'submit', 'value' => ''), + '/div' + ); + $this->assertTags($result, $expected); + $result = $this->Form->submit('Test Submit'); $expected = array( 'div' => array('class' => 'submit'), @@ -6482,6 +6526,24 @@ class FormHelperTest extends CakeTestCase { function testFormEnd() { $this->assertEqual($this->Form->end(), ''); + $result = $this->Form->end(''); + $expected = array( + 'div' => array('class' => 'submit'), + 'input' => array('type' => 'submit', 'value' => ''), + '/div', + '/form' + ); + $this->assertTags($result, $expected); + + $result = $this->Form->end(array('label' => '')); + $expected = array( + 'div' => array('class' => 'submit'), + 'input' => array('type' => 'submit', 'value' => ''), + '/div', + '/form' + ); + $this->assertTags($result, $expected); + $result = $this->Form->end('save'); $expected = array( 'div' => array('class' => 'submit'), diff --git a/cake/tests/cases/libs/view/helpers/js.test.php b/cake/tests/cases/libs/view/helpers/js.test.php index 36f9197cb..f4f39408e 100644 --- a/cake/tests/cases/libs/view/helpers/js.test.php +++ b/cake/tests/cases/libs/view/helpers/js.test.php @@ -483,7 +483,7 @@ class JsHelperTest extends CakeTestCase { function testSubmitWithMock() { $this->_useMock(); - $options = array('update' => '#content', 'id' => 'test-submit'); + $options = array('update' => '#content', 'id' => 'test-submit', 'style' => 'margin: 0'); $this->Js->TestJsEngine->expects($this->at(0)) ->method('get'); @@ -508,7 +508,7 @@ class JsHelperTest extends CakeTestCase { $result = $this->Js->submit('Save', $options); $expected = array( 'div' => array('class' => 'submit'), - 'input' => array('type' => 'submit', 'id' => $options['id'], 'value' => 'Save'), + 'input' => array('type' => 'submit', 'id' => $options['id'], 'value' => 'Save', 'style' => 'margin: 0'), '/div' ); $this->assertTags($result, $expected);