Permalink
Browse files

Start updating inputs().

  • Loading branch information...
markstory committed Mar 4, 2014
1 parent 4e44465 commit a5ed2c2d654aee01c313b27b106e51518258422a
Showing with 22 additions and 33 deletions.
  1. +5 −5 src/View/Helper/FormHelper.php
  2. +17 −28 tests/TestCase/View/Helper/FormHelperTest.php
@@ -732,12 +732,11 @@ protected function _domId($value) {
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html#FormHelper::inputs
*/
public function inputs($fields = null, $blacklist = null, $options = array()) {
+ $modelFields = [];
+ $model = false;
$fieldset = $legend = true;
- $modelFields = array();
- $model = $this->model();
- if ($model) {
- $modelFields = array_keys((array)$this->_introspectModel($model, 'fields'));
- }
+ $context = $this->_getContext();
+ // TODO add context->fields()
if (is_array($fields)) {
if (array_key_exists('legend', $fields) && !in_array('legend', $modelFields)) {
$legend = $fields['legend'];
@@ -769,6 +768,7 @@ public function inputs($fields = null, $blacklist = null, $options = array()) {
if ($legend === true) {
$actionName = __d('cake', 'New %s');
+ $isCreate = $context->isCreate();
$isEdit = (
strpos($this->request->params['action'], 'update') !== false ||
strpos($this->request->params['action'], 'edit') !== false
@@ -2525,48 +2525,37 @@ public function testFormInputsLegendFieldset() {
$result = $this->Form->inputs('Field of Dreams', null, array('fieldset' => 'classy-stuff'));
$this->assertTags($result, $expected);
- }
-/**
- * Test the inputs() method.
- *
- * @return void
- */
- public function testFormInputs() {
$this->Form->create($this->article);
- $this->Form->request['prefix'] = 'admin';
- $this->Form->request['action'] = 'admin_edit';
+ $this->Form->request->params['prefix'] = 'admin';
+ $this->Form->request->params['action'] = 'admin_edit';
+ $this->Form->request->params['controller'] = 'articles';
$result = $this->Form->inputs();
- $expected = array(
+ $expected = [
'<fieldset',
'<legend',
'Edit Article',
'/legend',
'*/fieldset',
- );
+ ];
$this->assertTags($result, $expected);
+ }
- $this->Form->create('Contact');
- $result = $this->Form->inputs(false);
+/**
+ * Test the inputs() method.
+ *
+ * @return void
+ */
+ public function testFormInputs() {
+ $this->Form->create($this->article);
+ $result = $this->Form->inputs(['id', 'title', 'body']);
$expected = array(
- 'input' => array('type' => 'hidden', 'name' => 'Contact[id]', 'id' => 'ContactId'),
+ 'input' => array('type' => 'hidden', 'name' => 'id', 'id' => 'id'),
array('div' => array('class' => 'input text')),
'*/div',
- array('div' => array('class' => 'input email')),
- '*/div',
- array('div' => array('class' => 'input tel')),
- '*/div',
- array('div' => array('class' => 'input password')),
- '*/div',
- array('div' => array('class' => 'input date')),
- '*/div',
- array('div' => array('class' => 'input date')),
- '*/div',
- array('div' => array('class' => 'input datetime')),
- '*/div',
- array('div' => array('class' => 'input number')),
+ array('div' => array('class' => 'input text')),
'*/div',
- array('div' => array('class' => 'input select')),
+ array('div' => array('class' => 'input textarea')),
'*/div',
);
$this->assertTags($result, $expected);

0 comments on commit a5ed2c2

Please sign in to comment.