Browse Source

HTML::entities() now optional on label contents

Chris How 12 years ago
parent
commit
f93dfccd21
2 changed files with 6 additions and 2 deletions
  1. 4 2
      laravel/form.php
  2. 2 0
      laravel/tests/cases/form.test.php

+ 4 - 2
laravel/form.php

@@ -182,13 +182,15 @@ class Form {
 	 * @param  array   $attributes
 	 * @return string
 	 */
-	public static function label($name, $value, $attributes = array())
+	public static function label($name, $value, $attributes = array(), $escape_html = true)
 	{
 		static::$labels[] = $name;
 
 		$attributes = HTML::attributes($attributes);
 
-		$value = HTML::entities($value);
+		if ($escape_html) {
+			$value = HTML::entities($value);
+		}
 
 		return '<label for="'.$name.'"'.$attributes.'>'.$value.'</label>';
 	}

+ 2 - 0
laravel/tests/cases/form.test.php

@@ -111,9 +111,11 @@ class FormTest extends PHPUnit_Framework_TestCase {
 	{
 		$form1 = Form::label('foo', 'Foobar');
 		$form2 = Form::label('foo', 'Foobar', array('class' => 'control-label'));
+		$form3 = Form::label('foo', 'Foobar <i>baz</i>', null, false);
 
 		$this->assertEquals('<label for="foo">Foobar</label>', $form1);
 		$this->assertEquals('<label for="foo" class="control-label">Foobar</label>', $form2);
+		$this->assertEquals('<label for="foo">Foobar <i>baz</i></label>', $form3);
 	}
 
 	/**