Merge branch '5.2' of https://github.com/LaravelCollective/html into blade-directives
This commit is contained in:
commit
e7d03053b3
6 files changed
+53
-15
No files matched your search
Executable → Regular
+8
-4
@@ -13,7 +13,6 @@ use Illuminate\Contracts\Routing\UrlGenerator;
|
||||
|
||||
class FormBuilder
|
||||
{
|
||||
|
||||
use Macroable, Componentable {
|
||||
Macroable::__call as macroCall;
|
||||
Componentable::__call as componentCall;
|
||||
@@ -210,16 +209,21 @@ class FormBuilder
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
* @param array $options
|
||||
* @param bool $escape_html
|
||||
*
|
||||
* @return \Illuminate\Support\HtmlString
|
||||
*/
|
||||
public function label($name, $value = null, $options = [])
|
||||
public function label($name, $value = null, $options = [], $escape_html = true)
|
||||
{
|
||||
$this->labels[] = $name;
|
||||
|
||||
$options = $this->html->attributes($options);
|
||||
|
||||
$value = e($this->formatLabel($name, $value));
|
||||
$value = $this->formatLabel($name, $value);
|
||||
|
||||
if ($escape_html) {
|
||||
$value = $this->html->entities($value);
|
||||
}
|
||||
|
||||
return $this->toHtmlString('<label for="' . $name . '"' . $options . '>' . $value . '</label>');
|
||||
}
|
||||
@@ -1080,7 +1084,7 @@ class FormBuilder
|
||||
return $value;
|
||||
}
|
||||
|
||||
if (! is_null($this->old($name))) {
|
||||
if (! is_null($this->old($name)) && $name != '_method') {
|
||||
return $this->old($name);
|
||||
}
|
||||
|
||||
|
||||
+14
-5
@@ -10,7 +10,6 @@ use Illuminate\Contracts\Routing\UrlGenerator;
|
||||
|
||||
class HtmlBuilder
|
||||
{
|
||||
|
||||
use Macroable, Componentable {
|
||||
Macroable::__call as macroCall;
|
||||
Componentable::__call as componentCall;
|
||||
@@ -147,10 +146,11 @@ class HtmlBuilder
|
||||
* @param string $title
|
||||
* @param array $attributes
|
||||
* @param bool $secure
|
||||
* @param bool $escape
|
||||
*
|
||||
* @return \Illuminate\Support\HtmlString
|
||||
*/
|
||||
public function link($url, $title = null, $attributes = [], $secure = null)
|
||||
public function link($url, $title = null, $attributes = [], $secure = null, $escape = true)
|
||||
{
|
||||
$url = $this->url->to($url, [], $secure);
|
||||
|
||||
@@ -158,7 +158,11 @@ class HtmlBuilder
|
||||
$title = $url;
|
||||
}
|
||||
|
||||
return $this->toHtmlString('<a href="' . $url . '"' . $this->attributes($attributes) . '>' . $this->entities($title) . '</a>');
|
||||
if ($escape) {
|
||||
$title = $this->entities($title);
|
||||
}
|
||||
|
||||
return $this->toHtmlString('<a href="' . $url . '"' . $this->attributes($attributes) . '>' . $title . '</a>');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -242,18 +246,23 @@ class HtmlBuilder
|
||||
* @param string $email
|
||||
* @param string $title
|
||||
* @param array $attributes
|
||||
* @param bool $escape
|
||||
*
|
||||
* @return \Illuminate\Support\HtmlString
|
||||
*/
|
||||
public function mailto($email, $title = null, $attributes = [])
|
||||
public function mailto($email, $title = null, $attributes = [], $escape = true)
|
||||
{
|
||||
$email = $this->email($email);
|
||||
|
||||
$title = $title ?: $email;
|
||||
|
||||
if ($escape) {
|
||||
$title = $this->entities($title);
|
||||
}
|
||||
|
||||
$email = $this->obfuscate('mailto:') . $email;
|
||||
|
||||
return $this->toHtmlString('<a href="' . $email . '"' . $this->attributes($attributes) . '>' . $this->entities($title) . '</a>');
|
||||
return $this->toHtmlString('<a href="' . $email . '"' . $this->attributes($attributes) . '>' . $title . '</a>');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+3
-2
@@ -8,12 +8,13 @@ if (! function_exists('link_to')) {
|
||||
* @param string $title
|
||||
* @param array $attributes
|
||||
* @param bool $secure
|
||||
* @param bool $escape
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function link_to($url, $title = null, $attributes = [], $secure = null)
|
||||
function link_to($url, $title = null, $attributes = [], $secure = null, $escape = true)
|
||||
{
|
||||
return app('html')->link($url, $title, $attributes, $secure);
|
||||
return app('html')->link($url, $title, $attributes, $secure, $escape);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user