Fixing undefined variable in Router, updating Socket test, and fixing FormHelper::label() for dot notation (Ticket #2277)

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4648 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
nate 2007-03-22 18:47:38 +00:00
parent c65f2a1fd2
commit 6b7d4f37d4
4 changed files with 15 additions and 7 deletions

View file

@ -776,7 +776,7 @@ if(!function_exists('http_build_query')) {
}
$out = array();
foreach((array)$data as $key => $val) {
foreach((array)$data as $key => $v) {
if(is_numeric($key) && !empty($prefix)) {
$key = $prefix . $key;
}

View file

@ -236,12 +236,12 @@ class FormHelper extends AppHelper {
*/
function label($tagName = null, $text = null, $attributes = array()) {
if (empty($tagName)) {
$tagName = implode('/', array_filter(array($this->model(), $this->field())));
$tagName = implode('.', array_filter(array($this->model(), $this->field())));
}
if ($text == null) {
if (strpos($tagName, '/') !== false) {
list( , $text) = explode('/', $tagName);
if (strpos($tagName, '/') !== false || strpos($tagName, '.') !== false) {
list( , $text) = preg_split('/[\/\.]+/', $tagName);
} else {
$text = $tagName;
}
@ -250,8 +250,8 @@ class FormHelper extends AppHelper {
}
$text = Inflector::humanize($text);
}
if (strpos($tagName, '/') !== false) {
$tagName = Inflector::camelize(r('/', '_', $tagName));
if (strpos($tagName, '/') !== false || strpos($tagName, '.') !== false) {
$tagName = Inflector::camelize(preg_replace('/[\/\.]+/', '_', $tagName));
}
return $this->output(sprintf($this->Html->tags['label'], $tagName, $this->_parseAttributes($attributes), $text));
}

View file

@ -49,7 +49,7 @@ class SocketTest extends UnitTestCase {
function testSocketHost() {
$this->assertEqual($this->socket->address(), '127.0.0.1');
$this->assertEqual($this->socket->host(), 'localhost');
$this->assertPattern('/local/', $this->socket->host());
$this->assertEqual($this->socket->lastError(), null);
$this->assertTrue(in_array('127.0.0.1', $this->socket->addresses()));
}

View file

@ -93,6 +93,14 @@ class FormHelperTest extends UnitTestCase {
$result = $this->Form->label();
$this->assertEqual($result, '<label for="PersonName">Name</label>');
$this->Form->text('Person.name');
$result = $this->Form->label();
$this->assertEqual($result, '<label for="PersonName">Name</label>');
$this->Form->text('Person.Name');
$result = $this->Form->label();
$this->assertEqual($result, '<label for="PersonName">Name</label>');
$result = $this->Form->label('first_name');
$this->assertEqual($result, '<label for="first_name">First Name</label>');