mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Moving FormHelper specifics into that class.
This commit is contained in:
parent
89258327c6
commit
c9acb6b587
2 changed files with 20 additions and 4 deletions
|
@ -296,10 +296,6 @@ class HelperTest extends CakeTestCase {
|
||||||
$this->Helper->setEntity('ModelThatDoesntExist.field_that_doesnt_exist');
|
$this->Helper->setEntity('ModelThatDoesntExist.field_that_doesnt_exist');
|
||||||
$expected = array('ModelThatDoesntExist', 'field_that_doesnt_exist');
|
$expected = array('ModelThatDoesntExist', 'field_that_doesnt_exist');
|
||||||
$this->assertEquals($expected, $this->Helper->entity());
|
$this->assertEquals($expected, $this->Helper->entity());
|
||||||
|
|
||||||
$this->Helper->setEntity('HelperTestTag');
|
|
||||||
$expected = array('HelperTestTag', 'HelperTestTag');
|
|
||||||
$this->assertEquals($expected, $this->Helper->entity());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2098,6 +2098,26 @@ class FormHelper extends AppHelper {
|
||||||
return $opt;
|
return $opt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
* Gets the input field name for the current tag
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue