Permalink
Browse files

Moving FormHelper specifics into that class.

  • Loading branch information...
1 parent 8925832 commit c9acb6b587c45f98fb7dca7e150242c472859c7c @markstory markstory committed Jul 1, 2011
Showing with 20 additions and 4 deletions.
  1. +0 −4 lib/Cake/Test/Case/View/HelperTest.php
  2. +20 −0 lib/Cake/View/Helper/FormHelper.php
@@ -296,10 +296,6 @@ public function testSetEntityScoped() {
$this->Helper->setEntity('ModelThatDoesntExist.field_that_doesnt_exist');
$expected = array('ModelThatDoesntExist', 'field_that_doesnt_exist');
$this->assertEquals($expected, $this->Helper->entity());
-
- $this->Helper->setEntity('HelperTestTag');
- $expected = array('HelperTestTag', 'HelperTestTag');
- $this->assertEquals($expected, $this->Helper->entity());
}
/**
@@ -2099,6 +2099,26 @@ public function dateTime($fieldName, $dateFormat = 'DMY', $timeFormat = '12', $a
}
/**
+ * Add support for special HABTM syntax.
+ *
+ * Sets this helper's model and field properties to the dot-separated value-pair in $entity.
+ *
+ * @param mixed $entity A field name, like "ModelName.fieldName" or "ModelName.ID.fieldName"
+ * @param boolean $setScope Sets the view scope to the model specified in $tagValue
+ * @return void
+ */
+ function setEntity($entity, $setScope = false) {
+ parent::setEntity($entity, $setScope);
+ $parts = explode('.', $entity);
+ if (
+ isset($this->fieldset[$this->_modelScope]['fields'][$parts[0]]['type']) &&
+ $this->fieldset[$this->_modelScope]['fields'][$parts[0]]['type'] === 'multiple'
+ ) {
+ $this->_entityPath = $parts[0] . '.' . $parts[0];
+ }
+ }
+
+/**
* Gets the input field name for the current tag
*
* @param array $options

0 comments on commit c9acb6b

Please sign in to comment.