Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
42c0854e00 | ||
|
|
38f2c6ff0d | ||
|
|
b3a10245c7 | ||
|
|
623a150c91 | ||
|
|
5060a6641d | ||
|
|
41cd9291a6 | ||
|
|
818efc2e16 | ||
|
|
e6496328af | ||
|
|
137a2efcf1 | ||
|
|
32c27a54cd | ||
|
|
f9deb1da6f | ||
|
|
5feb06537d | ||
|
|
e1318fcfdd | ||
|
|
cecb65626c | ||
|
|
2c5db92f66 | ||
|
|
7e49960e8f | ||
|
|
f3b55c6033 | ||
|
|
a5f7464ee6 | ||
|
|
cd71ed1538 | ||
|
|
e2fcbee917 | ||
|
|
2dfc110b6c | ||
|
|
8997f1209d | ||
|
|
ac46825a97 | ||
|
|
33dd7bb48e | ||
|
|
779d075f79 | ||
|
|
29253c13a3 | ||
|
|
d621ce1357 | ||
|
|
9e2a40555a | ||
|
|
8f7bc4d097 | ||
|
|
cf13e067eb | ||
|
|
b39f510897 | ||
|
|
b4c0a3e26d | ||
|
|
e6bc7e5fea | ||
|
|
1810274c8a | ||
|
|
f380cdc14d | ||
|
|
0ac9642ebb | ||
|
|
2f6dc39ab3 | ||
|
|
422ba2ea8d | ||
|
|
b9322c703d | ||
|
|
e3d9fe169d | ||
|
|
06d4296d18 | ||
|
|
97fa90bf64 | ||
|
|
79f59a016c | ||
|
|
3841eb8c89 | ||
|
|
adf0d91e2c | ||
|
|
3688b0e433 | ||
|
|
b91158bae5 | ||
|
|
471a0aa5e4 | ||
|
|
291da712f4 | ||
|
|
a47a02b962 | ||
|
|
d7aba64b44 | ||
|
|
e6471f3be1 |
No files matched your search
+1
-2
@@ -1,9 +1,8 @@
|
|||||||
language: php
|
language: php
|
||||||
|
|
||||||
php:
|
php:
|
||||||
- 5.6
|
|
||||||
- 7.0
|
|
||||||
- 7.1
|
- 7.1
|
||||||
|
- 7.2
|
||||||
|
|
||||||
sudo: false
|
sudo: false
|
||||||
|
|
||||||
|
|||||||
+53
-37
@@ -1,41 +1,57 @@
|
|||||||
{
|
{
|
||||||
"name": "laravelcollective/html",
|
"name": "laravelcollective/html",
|
||||||
"description": "HTML and Form Builders for the Laravel Framework",
|
"description": "HTML and Form Builders for the Laravel Framework",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"homepage": "http://laravelcollective.com",
|
"homepage": "https://laravelcollective.com",
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/LaravelCollective/html/issues",
|
"issues": "https://github.com/LaravelCollective/html/issues",
|
||||||
"source": "https://github.com/LaravelCollective/html"
|
"source": "https://github.com/LaravelCollective/html"
|
||||||
},
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Adam Engebretson",
|
|
||||||
"email": "adam@laravelcollective.com"
|
|
||||||
},
|
},
|
||||||
{
|
"authors": [
|
||||||
"name": "Taylor Otwell",
|
{
|
||||||
"email": "taylorotwell@gmail.com"
|
"name": "Adam Engebretson",
|
||||||
}
|
"email": "adam@laravelcollective.com"
|
||||||
],
|
},
|
||||||
"require": {
|
{
|
||||||
"php": ">=5.6.4",
|
"name": "Taylor Otwell",
|
||||||
"illuminate/http": "5.4.*",
|
"email": "taylorotwell@gmail.com"
|
||||||
"illuminate/routing": "5.4.*",
|
}
|
||||||
"illuminate/session": "5.4.*",
|
],
|
||||||
"illuminate/support": "5.4.*",
|
"require": {
|
||||||
"illuminate/view": "5.4.*"
|
"php": ">=7.1.3",
|
||||||
},
|
"illuminate/http": "5.6.*",
|
||||||
"require-dev": {
|
"illuminate/routing": "5.6.*",
|
||||||
"illuminate/database": "5.4.*",
|
"illuminate/session": "5.6.*",
|
||||||
"mockery/mockery": "~0.9.4",
|
"illuminate/support": "5.6.*",
|
||||||
"phpunit/phpunit": "~5.4"
|
"illuminate/view": "5.6.*"
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"Collective\\Html\\": "src/"
|
|
||||||
},
|
},
|
||||||
"files": [
|
"require-dev": {
|
||||||
"src/helpers.php"
|
"illuminate/database": "5.6.*",
|
||||||
]
|
"mockery/mockery": "~1.0",
|
||||||
}
|
"phpunit/phpunit": "~7.1"
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Collective\\Html\\": "src/"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"src/helpers.php"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "5.6-dev"
|
||||||
|
},
|
||||||
|
"laravel": {
|
||||||
|
"providers": [
|
||||||
|
"Collective\\Html\\HtmlServiceProvider"
|
||||||
|
],
|
||||||
|
"aliases": {
|
||||||
|
"Form": "Collective\\Html\\FormFacade",
|
||||||
|
"Html": "Collective\\Html\\HtmlFacade"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"minimum-stability": "dev",
|
||||||
|
"prefer-stable": true
|
||||||
}
|
}
|
||||||
@@ -49,11 +49,11 @@ trait FormAccessible
|
|||||||
unset($keys[0]);
|
unset($keys[0]);
|
||||||
$key = implode('.', $keys);
|
$key = implode('.', $keys);
|
||||||
|
|
||||||
if ($this->hasFormMutator($key)) {
|
if (method_exists($relatedModel, 'hasFormMutator') && $key !== '' && $relatedModel->hasFormMutator($key)) {
|
||||||
return $relatedModel->getFormValue($key);
|
return $relatedModel->getFormValue($key);
|
||||||
}
|
}
|
||||||
|
|
||||||
return data_get($relatedModel, $key);
|
return data_get($relatedModel, empty($key)? null: $key);
|
||||||
}
|
}
|
||||||
|
|
||||||
// No form mutator, let the model resolve this
|
// No form mutator, let the model resolve this
|
||||||
@@ -81,13 +81,13 @@ trait FormAccessible
|
|||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function hasFormMutator($key)
|
public function hasFormMutator($key)
|
||||||
{
|
{
|
||||||
$methods = $this->getReflection()->getMethods(ReflectionMethod::IS_PUBLIC);
|
$methods = $this->getReflection()->getMethods(ReflectionMethod::IS_PUBLIC);
|
||||||
|
|
||||||
$mutator = collect($methods)
|
$mutator = collect($methods)
|
||||||
->first(function (ReflectionMethod $method) use ($key) {
|
->first(function (ReflectionMethod $method) use ($key) {
|
||||||
return $method->getName() == 'form' . Str::studly($key) . 'Attribute';
|
return $method->getName() === 'form' . Str::studly($key) . 'Attribute';
|
||||||
});
|
});
|
||||||
|
|
||||||
return (bool) $mutator;
|
return (bool) $mutator;
|
||||||
|
|||||||
+125
-30
@@ -191,6 +191,16 @@ class FormBuilder
|
|||||||
$this->model = $model;
|
$this->model = $model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current model instance on the form builder.
|
||||||
|
*
|
||||||
|
* @return mixed $model
|
||||||
|
*/
|
||||||
|
public function getModel()
|
||||||
|
{
|
||||||
|
return $this->model;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close the current form.
|
* Close the current form.
|
||||||
*
|
*
|
||||||
@@ -319,6 +329,20 @@ class FormBuilder
|
|||||||
return $this->input('password', $name, '', $options);
|
return $this->input('password', $name, '', $options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a range input field.
|
||||||
|
*
|
||||||
|
* @param string $name
|
||||||
|
* @param string $value
|
||||||
|
* @param array $options
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Support\HtmlString
|
||||||
|
*/
|
||||||
|
public function range($name, $value = null, $options = [])
|
||||||
|
{
|
||||||
|
return $this->input('range', $name, $value, $options);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a hidden input field.
|
* Create a hidden input field.
|
||||||
*
|
*
|
||||||
@@ -454,6 +478,10 @@ class FormBuilder
|
|||||||
*/
|
*/
|
||||||
public function time($name, $value = null, $options = [])
|
public function time($name, $value = null, $options = [])
|
||||||
{
|
{
|
||||||
|
if ($value instanceof DateTime) {
|
||||||
|
$value = $value->format('H:i');
|
||||||
|
}
|
||||||
|
|
||||||
return $this->input('time', $name, $value, $options);
|
return $this->input('time', $name, $value, $options);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -471,6 +499,24 @@ class FormBuilder
|
|||||||
return $this->input('url', $name, $value, $options);
|
return $this->input('url', $name, $value, $options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a week input field.
|
||||||
|
*
|
||||||
|
* @param string $name
|
||||||
|
* @param string $value
|
||||||
|
* @param array $options
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Support\HtmlString
|
||||||
|
*/
|
||||||
|
public function week($name, $value = null, $options = [])
|
||||||
|
{
|
||||||
|
if ($value instanceof DateTime) {
|
||||||
|
$value = $value->format('Y-\WW');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->input('week', $name, $value, $options);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a file input field.
|
* Create a file input field.
|
||||||
*
|
*
|
||||||
@@ -517,7 +563,7 @@ class FormBuilder
|
|||||||
// the element. Then we'll create the final textarea elements HTML for us.
|
// the element. Then we'll create the final textarea elements HTML for us.
|
||||||
$options = $this->html->attributes($options);
|
$options = $this->html->attributes($options);
|
||||||
|
|
||||||
return $this->toHtmlString('<textarea' . $options . '>' . e($value). '</textarea>');
|
return $this->toHtmlString('<textarea' . $options . '>' . e($value, false). '</textarea>');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -562,9 +608,10 @@ class FormBuilder
|
|||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param array $list
|
* @param array $list
|
||||||
* @param string $selected
|
* @param string|bool $selected
|
||||||
* @param array $selectAttributes
|
* @param array $selectAttributes
|
||||||
* @param array $optionsAttributes
|
* @param array $optionsAttributes
|
||||||
|
* @param array $optgroupsAttributes
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Support\HtmlString
|
* @return \Illuminate\Support\HtmlString
|
||||||
*/
|
*/
|
||||||
@@ -573,7 +620,8 @@ class FormBuilder
|
|||||||
$list = [],
|
$list = [],
|
||||||
$selected = null,
|
$selected = null,
|
||||||
array $selectAttributes = [],
|
array $selectAttributes = [],
|
||||||
array $optionsAttributes = []
|
array $optionsAttributes = [],
|
||||||
|
array $optgroupsAttributes = []
|
||||||
) {
|
) {
|
||||||
$this->type = 'select';
|
$this->type = 'select';
|
||||||
|
|
||||||
@@ -599,8 +647,9 @@ class FormBuilder
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ($list as $value => $display) {
|
foreach ($list as $value => $display) {
|
||||||
$optionAttributes = isset($optionsAttributes[$value]) ? $optionsAttributes[$value] : [];
|
$optionAttributes = $optionsAttributes[$value] ?? [];
|
||||||
$html[] = $this->getSelectOption($display, $value, $selected, $optionAttributes);
|
$optgroupAttributes = $optgroupsAttributes[$value] ?? [];
|
||||||
|
$html[] = $this->getSelectOption($display, $value, $selected, $optionAttributes, $optgroupAttributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Once we have all of this HTML, we can join this into a single element after
|
// Once we have all of this HTML, we can join this into a single element after
|
||||||
@@ -675,13 +724,14 @@ class FormBuilder
|
|||||||
* @param string $value
|
* @param string $value
|
||||||
* @param string $selected
|
* @param string $selected
|
||||||
* @param array $attributes
|
* @param array $attributes
|
||||||
|
* @param array $optgroupAttributes
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Support\HtmlString
|
* @return \Illuminate\Support\HtmlString
|
||||||
*/
|
*/
|
||||||
public function getSelectOption($display, $value, $selected, array $attributes = [])
|
public function getSelectOption($display, $value, $selected, array $attributes = [], array $optgroupAttributes = [])
|
||||||
{
|
{
|
||||||
if (is_array($display)) {
|
if (is_array($display)) {
|
||||||
return $this->optionGroup($display, $value, $selected, $attributes);
|
return $this->optionGroup($display, $value, $selected, $optgroupAttributes, $attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->option($display, $value, $selected, $attributes);
|
return $this->option($display, $value, $selected, $attributes);
|
||||||
@@ -694,18 +744,24 @@ class FormBuilder
|
|||||||
* @param string $label
|
* @param string $label
|
||||||
* @param string $selected
|
* @param string $selected
|
||||||
* @param array $attributes
|
* @param array $attributes
|
||||||
|
* @param array $optionsAttributes
|
||||||
|
* @param integer $level
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Support\HtmlString
|
* @return \Illuminate\Support\HtmlString
|
||||||
*/
|
*/
|
||||||
protected function optionGroup($list, $label, $selected, array $attributes = [])
|
protected function optionGroup($list, $label, $selected, array $attributes = [], array $optionsAttributes = [], $level = 0)
|
||||||
{
|
{
|
||||||
$html = [];
|
$html = [];
|
||||||
|
$space = str_repeat(" ", $level);
|
||||||
foreach ($list as $value => $display) {
|
foreach ($list as $value => $display) {
|
||||||
$html[] = $this->option($display, $value, $selected, $attributes);
|
$optionAttributes = $optionsAttributes[$value] ?? [];
|
||||||
|
if (is_array($display)) {
|
||||||
|
$html[] = $this->optionGroup($display, $value, $selected, $attributes, $optionAttributes, $level+5);
|
||||||
|
} else {
|
||||||
|
$html[] = $this->option($space.$display, $value, $selected, $optionAttributes);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return $this->toHtmlString('<optgroup label="' . e($space.$label, false) . '"' . $this->html->attributes($attributes) . '>' . implode('', $html) . '</optgroup>');
|
||||||
return $this->toHtmlString('<optgroup label="' . e($label) . '">' . implode('', $html) . '</optgroup>');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -722,9 +778,14 @@ class FormBuilder
|
|||||||
{
|
{
|
||||||
$selected = $this->getSelectedValue($value, $selected);
|
$selected = $this->getSelectedValue($value, $selected);
|
||||||
|
|
||||||
$options = ['value' => $value, 'selected' => $selected] + $attributes;
|
$options = array_merge(['value' => $value, 'selected' => $selected], $attributes);
|
||||||
|
|
||||||
return $this->toHtmlString('<option' . $this->html->attributes($options) . '>' . e($display) . '</option>');
|
$string = '<option' . $this->html->attributes($options) . '>';
|
||||||
|
if ($display !== null) {
|
||||||
|
$string .= e($display, false) . '</option>';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->toHtmlString($string);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -744,7 +805,7 @@ class FormBuilder
|
|||||||
'value' => '',
|
'value' => '',
|
||||||
];
|
];
|
||||||
|
|
||||||
return $this->toHtmlString('<option' . $this->html->attributes($options) . '>' . e($display) . '</option>');
|
return $this->toHtmlString('<option' . $this->html->attributes($options) . '>' . e($display, false) . '</option>');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -762,8 +823,10 @@ class FormBuilder
|
|||||||
} elseif ($selected instanceof Collection) {
|
} elseif ($selected instanceof Collection) {
|
||||||
return $selected->contains($value) ? 'selected' : null;
|
return $selected->contains($value) ? 'selected' : null;
|
||||||
}
|
}
|
||||||
|
if (is_int($value) && is_bool($selected)) {
|
||||||
return ((string) $value == (string) $selected) ? 'selected' : null;
|
return (bool)$value === $selected;
|
||||||
|
}
|
||||||
|
return ((string) $value === (string) $selected) ? 'selected' : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -844,7 +907,7 @@ class FormBuilder
|
|||||||
return $this->getRadioCheckedState($name, $value, $checked);
|
return $this->getRadioCheckedState($name, $value, $checked);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return $this->getValueAttribute($name) == $value;
|
return $this->compareValues($name, $value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -865,7 +928,7 @@ class FormBuilder
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->missingOldAndModel($name) && !$request) {
|
if ($this->missingOldAndModel($name) && is_null($request)) {
|
||||||
return $checked;
|
return $checked;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -897,6 +960,20 @@ class FormBuilder
|
|||||||
return $checked;
|
return $checked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $this->compareValues($name, $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if the provide value loosely compares to the value assigned to the field.
|
||||||
|
* Use loose comparison because Laravel model casting may be in affect and therefore
|
||||||
|
* 1 == true and 0 == false.
|
||||||
|
*
|
||||||
|
* @param string $name
|
||||||
|
* @param string $value
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function compareValues($name, $value)
|
||||||
|
{
|
||||||
return $this->getValueAttribute($name) == $value;
|
return $this->getValueAttribute($name) == $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -941,6 +1018,24 @@ class FormBuilder
|
|||||||
return $this->input('image', $name, null, $attributes);
|
return $this->input('image', $name, null, $attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a month input field.
|
||||||
|
*
|
||||||
|
* @param string $name
|
||||||
|
* @param string $value
|
||||||
|
* @param array $options
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Support\HtmlString
|
||||||
|
*/
|
||||||
|
public function month($name, $value = null, $options = [])
|
||||||
|
{
|
||||||
|
if ($value instanceof DateTime) {
|
||||||
|
$value = $value->format('Y-m');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->input('month', $name, $value, $options);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a color input field.
|
* Create a color input field.
|
||||||
*
|
*
|
||||||
@@ -996,7 +1091,7 @@ class FormBuilder
|
|||||||
{
|
{
|
||||||
$method = strtoupper($method);
|
$method = strtoupper($method);
|
||||||
|
|
||||||
return $method != 'GET' ? 'POST' : $method;
|
return $method !== 'GET' ? 'POST' : $method;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1098,7 +1193,7 @@ class FormBuilder
|
|||||||
// If the method is something other than GET we will go ahead and attach the
|
// If the method is something other than GET we will go ahead and attach the
|
||||||
// CSRF token to the form, as this can't hurt and is convenient to simply
|
// CSRF token to the form, as this can't hurt and is convenient to simply
|
||||||
// always have available on every form the developers creates for them.
|
// always have available on every form the developers creates for them.
|
||||||
if ($method != 'GET') {
|
if ($method !== 'GET') {
|
||||||
$appendage .= $this->token();
|
$appendage .= $this->token();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1140,7 +1235,7 @@ class FormBuilder
|
|||||||
|
|
||||||
$old = $this->old($name);
|
$old = $this->old($name);
|
||||||
|
|
||||||
if (! is_null($old) && $name != '_method') {
|
if (! is_null($old) && $name !== '_method') {
|
||||||
return $old;
|
return $old;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1151,7 +1246,7 @@ class FormBuilder
|
|||||||
if ($hasNullMiddleware
|
if ($hasNullMiddleware
|
||||||
&& is_null($old)
|
&& is_null($old)
|
||||||
&& is_null($value)
|
&& is_null($value)
|
||||||
&& !is_null($this->view->shared('errors'))
|
&& ! is_null($this->view->shared('errors'))
|
||||||
&& count($this->view->shared('errors')) > 0
|
&& count($this->view->shared('errors')) > 0
|
||||||
) {
|
) {
|
||||||
return null;
|
return null;
|
||||||
@@ -1159,7 +1254,7 @@ class FormBuilder
|
|||||||
}
|
}
|
||||||
|
|
||||||
$request = $this->request($name);
|
$request = $this->request($name);
|
||||||
if (!is_null($request)) {
|
if (! is_null($request) && $name != '_method') {
|
||||||
return $request;
|
return $request;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1179,7 +1274,7 @@ class FormBuilder
|
|||||||
*/
|
*/
|
||||||
protected function request($name)
|
protected function request($name)
|
||||||
{
|
{
|
||||||
if (!isset($this->request)) {
|
if (! isset($this->request)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1217,16 +1312,16 @@ class FormBuilder
|
|||||||
$key = $this->transformKey($name);
|
$key = $this->transformKey($name);
|
||||||
$payload = $this->session->getOldInput($key);
|
$payload = $this->session->getOldInput($key);
|
||||||
|
|
||||||
if (!is_array($payload)) {
|
if (! is_array($payload)) {
|
||||||
return $payload;
|
return $payload;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!in_array($this->type, ['select', 'checkbox'])) {
|
if (! in_array($this->type, ['select', 'checkbox'])) {
|
||||||
if (!isset($this->payload[$key])) {
|
if (! isset($this->payload[$key])) {
|
||||||
$this->payload[$key] = collect($payload);
|
$this->payload[$key] = collect($payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($this->payload[$key])) {
|
if (! empty($this->payload[$key])) {
|
||||||
$value = $this->payload[$key]->shift();
|
$value = $this->payload[$key]->shift();
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
@@ -1243,7 +1338,7 @@ class FormBuilder
|
|||||||
*/
|
*/
|
||||||
public function oldInputIsEmpty()
|
public function oldInputIsEmpty()
|
||||||
{
|
{
|
||||||
return (isset($this->session) && count($this->session->getOldInput()) == 0);
|
return (isset($this->session) && count((array) $this->session->getOldInput()) === 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+13
-13
@@ -78,7 +78,7 @@ class HtmlBuilder
|
|||||||
{
|
{
|
||||||
$attributes['src'] = $this->url->asset($url, $secure);
|
$attributes['src'] = $this->url->asset($url, $secure);
|
||||||
|
|
||||||
return $this->toHtmlString('<script' . $this->attributes($attributes) . '></script>' . PHP_EOL);
|
return $this->toHtmlString('<script' . $this->attributes($attributes) . '></script>');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -94,11 +94,11 @@ class HtmlBuilder
|
|||||||
{
|
{
|
||||||
$defaults = ['media' => 'all', 'type' => 'text/css', 'rel' => 'stylesheet'];
|
$defaults = ['media' => 'all', 'type' => 'text/css', 'rel' => 'stylesheet'];
|
||||||
|
|
||||||
$attributes = $attributes + $defaults;
|
$attributes = array_merge($defaults, $attributes);
|
||||||
|
|
||||||
$attributes['href'] = $this->url->asset($url, $secure);
|
$attributes['href'] = $this->url->asset($url, $secure);
|
||||||
|
|
||||||
return $this->toHtmlString('<link' . $this->attributes($attributes) . '>' . PHP_EOL);
|
return $this->toHtmlString('<link' . $this->attributes($attributes) . '>');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -132,11 +132,11 @@ class HtmlBuilder
|
|||||||
{
|
{
|
||||||
$defaults = ['rel' => 'shortcut icon', 'type' => 'image/x-icon'];
|
$defaults = ['rel' => 'shortcut icon', 'type' => 'image/x-icon'];
|
||||||
|
|
||||||
$attributes = $attributes + $defaults;
|
$attributes = array_merge($attributes, $defaults);
|
||||||
|
|
||||||
$attributes['href'] = $this->url->asset($url, $secure);
|
$attributes['href'] = $this->url->asset($url, $secure);
|
||||||
|
|
||||||
return $this->toHtmlString('<link' . $this->attributes($attributes) . '>' . PHP_EOL);
|
return $this->toHtmlString('<link' . $this->attributes($attributes) . '>');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -162,7 +162,7 @@ class HtmlBuilder
|
|||||||
$title = $this->entities($title);
|
$title = $this->entities($title);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->toHtmlString('<a href="' . $url . '"' . $this->attributes($attributes) . '>' . $title . '</a>');
|
return $this->toHtmlString('<a href="' . $this->entities($url) . '"' . $this->attributes($attributes) . '>' . $title . '</a>');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -357,7 +357,7 @@ class HtmlBuilder
|
|||||||
{
|
{
|
||||||
$html = '';
|
$html = '';
|
||||||
|
|
||||||
if (count($list) == 0) {
|
if (count($list) === 0) {
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -387,7 +387,7 @@ class HtmlBuilder
|
|||||||
if (is_array($value)) {
|
if (is_array($value)) {
|
||||||
return $this->nestedListing($key, $type, $value);
|
return $this->nestedListing($key, $type, $value);
|
||||||
} else {
|
} else {
|
||||||
return '<li>' . e($value) . '</li>';
|
return '<li>' . e($value, false) . '</li>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -451,12 +451,12 @@ class HtmlBuilder
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Treat boolean attributes as HTML properties
|
// Treat boolean attributes as HTML properties
|
||||||
if (is_bool($value) && $key != 'value') {
|
if (is_bool($value) && $key !== 'value') {
|
||||||
return $value ? $key : '';
|
return $value ? $key : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! is_null($value)) {
|
if (! is_null($value)) {
|
||||||
return $key . '="' . e($value) . '"';
|
return $key . '="' . e($value, false) . '"';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -511,7 +511,7 @@ class HtmlBuilder
|
|||||||
|
|
||||||
$attributes = array_merge($defaults, $attributes);
|
$attributes = array_merge($defaults, $attributes);
|
||||||
|
|
||||||
return $this->toHtmlString('<meta' . $this->attributes($attributes) . '>' . PHP_EOL);
|
return $this->toHtmlString('<meta' . $this->attributes($attributes) . '>');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -525,8 +525,8 @@ class HtmlBuilder
|
|||||||
*/
|
*/
|
||||||
public function tag($tag, $content, array $attributes = [])
|
public function tag($tag, $content, array $attributes = [])
|
||||||
{
|
{
|
||||||
$content = is_array($content) ? implode(PHP_EOL, $content) : $content;
|
$content = is_array($content) ? implode('', $content) : $content;
|
||||||
return $this->toHtmlString('<' . $tag . $this->attributes($attributes) . '>' . PHP_EOL . $this->toHtmlString($content) . PHP_EOL . '</' . $tag . '>' . PHP_EOL);
|
return $this->toHtmlString('<' . $tag . $this->attributes($attributes) . '>' . $this->toHtmlString($content) . '</' . $tag . '>');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ use Illuminate\Routing\UrlGenerator;
|
|||||||
use Illuminate\Database\Capsule\Manager as Capsule;
|
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||||
use Mockery as m;
|
use Mockery as m;
|
||||||
|
|
||||||
class FormAccessibleTest extends PHPUnit_Framework_TestCase
|
class FormAccessibleTest extends PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
@@ -42,10 +42,16 @@ class FormAccessibleTest extends PHPUnit_Framework_TestCase
|
|||||||
public function testItCanMutateValuesForForms()
|
public function testItCanMutateValuesForForms()
|
||||||
{
|
{
|
||||||
$model = new ModelThatUsesForms($this->modelData);
|
$model = new ModelThatUsesForms($this->modelData);
|
||||||
|
$user = new User(['name' => 'Anton']);
|
||||||
|
$model->setRelation('user', $user);
|
||||||
$this->formBuilder->setModel($model);
|
$this->formBuilder->setModel($model);
|
||||||
|
|
||||||
$this->assertEquals($model->getFormValue('string'), 'ponmlkjihgfedcba');
|
$this->assertEquals($model->getFormValue('string'), 'ponmlkjihgfedcba');
|
||||||
$this->assertEquals($model->getFormValue('created_at'), $this->now->timestamp);
|
$this->assertEquals($model->getFormValue('created_at'), $this->now->timestamp);
|
||||||
|
|
||||||
|
$this->assertEquals($user, $model->getFormValue('user'));
|
||||||
|
$this->assertEquals('Get name: Anton', $model->getFormValue('user')->name);
|
||||||
|
$this->assertEquals('Get name for form: Anton', $model->getFormValue('user.name'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testItCanMutateRelatedValuesForForms()
|
public function testItCanMutateRelatedValuesForForms()
|
||||||
@@ -68,12 +74,12 @@ class FormAccessibleTest extends PHPUnit_Framework_TestCase
|
|||||||
$model = new ModelThatUsesForms($this->modelData);
|
$model = new ModelThatUsesForms($this->modelData);
|
||||||
$this->assertEquals($model->getFormValue('address.street'), 'abcde st');
|
$this->assertEquals($model->getFormValue('address.street'), 'abcde st');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testItCanUseGetAccessorValuesWhenThereAreNoFormAccessors()
|
public function testItCanUseGetAccessorValuesWhenThereAreNoFormAccessors()
|
||||||
{
|
{
|
||||||
$model = new ModelThatUsesForms($this->modelData);
|
$model = new ModelThatUsesForms($this->modelData);
|
||||||
$this->formBuilder->setModel($model);
|
$this->formBuilder->setModel($model);
|
||||||
|
|
||||||
$this->assertEquals($this->formBuilder->getValueAttribute('email'), 'mutated@tjshafer.com');
|
$this->assertEquals($this->formBuilder->getValueAttribute('email'), 'mutated@tjshafer.com');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,3 +165,18 @@ class ModelThatDoesntUseForms extends Model
|
|||||||
return '1 second ago';
|
return '1 second ago';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class User extends Model
|
||||||
|
{
|
||||||
|
use FormAccessible;
|
||||||
|
|
||||||
|
public function formNameAttribute($value)
|
||||||
|
{
|
||||||
|
return 'Get name for form: ' . $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getNameAttribute($value)
|
||||||
|
{
|
||||||
|
return 'Get name: ' . $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,7 +11,7 @@ use Illuminate\Support\Facades\App;
|
|||||||
use Illuminate\Session\Store;
|
use Illuminate\Session\Store;
|
||||||
use Mockery as m;
|
use Mockery as m;
|
||||||
|
|
||||||
class FormBuilderTest extends PHPUnit_Framework_TestCase
|
class FormBuilderTest extends PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var FormBuilder
|
* @var FormBuilder
|
||||||
@@ -229,6 +229,17 @@ class FormBuilderTest extends PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals('<input class="span2" name="foo" type="password" value="">', $form2);
|
$this->assertEquals('<input class="span2" name="foo" type="password" value="">', $form2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testFormRange()
|
||||||
|
{
|
||||||
|
$form1 = $this->formBuilder->range('foo');
|
||||||
|
$form2 = $this->formBuilder->range('foo', 1);
|
||||||
|
$form3 = $this->formBuilder->range('foo', null, ['class' => 'span2']);
|
||||||
|
|
||||||
|
$this->assertEquals('<input name="foo" type="range">', $form1);
|
||||||
|
$this->assertEquals('<input name="foo" type="range" value="1">', $form2);
|
||||||
|
$this->assertEquals('<input class="span2" name="foo" type="range">', $form3);
|
||||||
|
}
|
||||||
|
|
||||||
public function testFormHidden()
|
public function testFormHidden()
|
||||||
{
|
{
|
||||||
$form1 = $this->formBuilder->hidden('foo');
|
$form1 = $this->formBuilder->hidden('foo');
|
||||||
@@ -240,6 +251,18 @@ class FormBuilderTest extends PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals('<input class="span2" name="foo" type="hidden">', $form3);
|
$this->assertEquals('<input class="span2" name="foo" type="hidden">', $form3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testFormMonth()
|
||||||
|
{
|
||||||
|
$form1 = $this->formBuilder->month('foo');
|
||||||
|
$form2 = $this->formBuilder->month('foo', \Carbon\Carbon::now());
|
||||||
|
$form3 = $this->formBuilder->month('foo', null, ['class' => 'span2']);
|
||||||
|
|
||||||
|
$this->assertEquals('<input name="foo" type="month">', $form1);
|
||||||
|
$this->assertEquals('<input name="foo" type="month" value="' . \Carbon\Carbon::now()->format('Y-m') . '">',
|
||||||
|
$form2);
|
||||||
|
$this->assertEquals('<input class="span2" name="foo" type="month">', $form3);
|
||||||
|
}
|
||||||
|
|
||||||
public function testFormSearch()
|
public function testFormSearch()
|
||||||
{
|
{
|
||||||
$form1 = $this->formBuilder->search('foo');
|
$form1 = $this->formBuilder->search('foo');
|
||||||
@@ -310,6 +333,29 @@ class FormBuilderTest extends PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals('<input class="span2" name="foo" type="time">', $form3);
|
$this->assertEquals('<input class="span2" name="foo" type="time">', $form3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testFormUrl()
|
||||||
|
{
|
||||||
|
$form1 = $this->formBuilder->url('foo');
|
||||||
|
$form2 = $this->formBuilder->url('foo', 'http://foobar.com');
|
||||||
|
$form3 = $this->formBuilder->url('foo', null, ['class' => 'span2']);
|
||||||
|
|
||||||
|
$this->assertEquals('<input name="foo" type="url">', $form1);
|
||||||
|
$this->assertEquals('<input name="foo" type="url" value="http://foobar.com">', $form2);
|
||||||
|
$this->assertEquals('<input class="span2" name="foo" type="url">', $form3);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testFormWeek()
|
||||||
|
{
|
||||||
|
$form1 = $this->formBuilder->week('foo');
|
||||||
|
$form2 = $this->formBuilder->week('foo', \Carbon\Carbon::now());
|
||||||
|
$form3 = $this->formBuilder->week('foo', null, ['class' => 'span2']);
|
||||||
|
|
||||||
|
$this->assertEquals('<input name="foo" type="week">', $form1);
|
||||||
|
$this->assertEquals('<input name="foo" type="week" value="' . \Carbon\Carbon::now()->format('Y-\WW') . '">',
|
||||||
|
$form2);
|
||||||
|
$this->assertEquals('<input class="span2" name="foo" type="week">', $form3);
|
||||||
|
}
|
||||||
|
|
||||||
public function testFormFile()
|
public function testFormFile()
|
||||||
{
|
{
|
||||||
$form1 = $this->formBuilder->file('foo');
|
$form1 = $this->formBuilder->file('foo');
|
||||||
@@ -402,6 +448,37 @@ class FormBuilderTest extends PHPUnit_Framework_TestCase
|
|||||||
'<select class="class-name" id="select-id" name="size"><optgroup label="Large sizes"><option value="L">Large</option><option value="XL">Extra Large</option></optgroup><option value="S">Small</option></select>'
|
'<select class="class-name" id="select-id" name="size"><optgroup label="Large sizes"><option value="L">Large</option><option value="XL">Extra Large</option></optgroup><option value="S">Small</option></select>'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$select = $this->formBuilder->select(
|
||||||
|
'size',
|
||||||
|
[
|
||||||
|
'Large sizes' => [
|
||||||
|
'L' => 'Large',
|
||||||
|
'XL' => 'Extra Large',
|
||||||
|
],
|
||||||
|
'M' => 'Medium',
|
||||||
|
'Small sizes' => [
|
||||||
|
'S' => 'Small',
|
||||||
|
'XS' => 'Extra Small',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
null,
|
||||||
|
[],
|
||||||
|
[
|
||||||
|
'Large sizes' => [
|
||||||
|
'L' => ['disabled']
|
||||||
|
],
|
||||||
|
'M' => ['disabled'],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'Small sizes' => ['disabled'],
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertEquals(
|
||||||
|
$select,
|
||||||
|
'<select name="size"><optgroup label="Large sizes"><option value="L" disabled>Large</option><option value="XL">Extra Large</option></optgroup><option value="M" disabled>Medium</option><optgroup label="Small sizes" disabled><option value="S">Small</option><option value="XS">Extra Small</option></optgroup></select>'
|
||||||
|
);
|
||||||
|
|
||||||
$select = $this->formBuilder->select(
|
$select = $this->formBuilder->select(
|
||||||
'encoded_html',
|
'encoded_html',
|
||||||
['no_break_space' => ' ', 'ampersand' => '&', 'lower_than' => '<'],
|
['no_break_space' => ' ', 'ampersand' => '&', 'lower_than' => '<'],
|
||||||
@@ -433,6 +510,12 @@ class FormBuilderTest extends PHPUnit_Framework_TestCase
|
|||||||
'<select name="countries"><option value="1" selected="selected">L</option><option value="2">M</option></select>',
|
'<select name="countries"><option value="1" selected="selected">L</option><option value="2">M</option></select>',
|
||||||
$result
|
$result
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$select = $this->formBuilder->select('avc', [1 => 'Yes', 0 => 'No'], true, ['placeholder' => 'Select']);
|
||||||
|
$this->assertEquals(
|
||||||
|
'<select name="avc"><option value="">Select</option><option value="1" selected>Yes</option><option value="0" >No</option></select>',
|
||||||
|
$select
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSelectCollection()
|
public function testSelectCollection()
|
||||||
@@ -621,6 +704,21 @@ class FormBuilderTest extends PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals('<input class="span2" name="foo" type="radio" value="foobar">', $form4);
|
$this->assertEquals('<input class="span2" name="foo" type="radio" value="foobar">', $form4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testFormRadioWithAttributeCastToBoolean()
|
||||||
|
{
|
||||||
|
$this->setModel(['itemA' => true, 'itemB' => false]);
|
||||||
|
|
||||||
|
$radio1 = $this->formBuilder->radio('itemA', 1);
|
||||||
|
$radio2 = $this->formBuilder->radio('itemA', 0);
|
||||||
|
$radio3 = $this->formBuilder->radio('itemB', 1);
|
||||||
|
$radio4 = $this->formBuilder->radio('itemB', 0);
|
||||||
|
|
||||||
|
$this->assertEquals('<input checked="checked" name="itemA" type="radio" value="1">', $radio1);
|
||||||
|
$this->assertEquals('<input name="itemA" type="radio" value="0">', $radio2);
|
||||||
|
$this->assertEquals('<input name="itemB" type="radio" value="1">', $radio3);
|
||||||
|
$this->assertEquals('<input checked="checked" name="itemB" type="radio" value="0">', $radio4);
|
||||||
|
}
|
||||||
|
|
||||||
public function testFormRadioRepopulation()
|
public function testFormRadioRepopulation()
|
||||||
{
|
{
|
||||||
$this->formBuilder->setSessionStore($session = m::mock('Illuminate\Contracts\Session\Session'));
|
$this->formBuilder->setSessionStore($session = m::mock('Illuminate\Contracts\Session\Session'));
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use Illuminate\Routing\RouteCollection;
|
|||||||
use Illuminate\Routing\UrlGenerator;
|
use Illuminate\Routing\UrlGenerator;
|
||||||
use Mockery as m;
|
use Mockery as m;
|
||||||
|
|
||||||
class HtmlBuilderTest extends PHPUnit_Framework_TestCase
|
class HtmlBuilderTest extends PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -65,7 +65,7 @@ class HtmlBuilderTest extends PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$result = $this->htmlBuilder->meta('description', 'Lorem ipsum dolor sit amet.');
|
$result = $this->htmlBuilder->meta('description', 'Lorem ipsum dolor sit amet.');
|
||||||
|
|
||||||
$this->assertEquals('<meta name="description" content="Lorem ipsum dolor sit amet.">' . PHP_EOL, $result);
|
$this->assertEquals('<meta name="description" content="Lorem ipsum dolor sit amet.">', $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testTag()
|
public function testTag()
|
||||||
@@ -83,17 +83,17 @@ class HtmlBuilderTest extends PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$result4 = $this->htmlBuilder->tag('div', $content, ['class' => 'row']);
|
$result4 = $this->htmlBuilder->tag('div', $content, ['class' => 'row']);
|
||||||
|
|
||||||
$this->assertEquals('<p>' . PHP_EOL . 'Lorem ipsum dolor sit amet.' . PHP_EOL . '</p>' . PHP_EOL, $result1);
|
$this->assertEquals('<p>Lorem ipsum dolor sit amet.</p>', $result1);
|
||||||
$this->assertEquals('<p class="text-center">' . PHP_EOL . 'Lorem ipsum dolor sit amet.' . PHP_EOL . '</p>' . PHP_EOL, $result2);
|
$this->assertEquals('<p class="text-center">Lorem ipsum dolor sit amet.</p>', $result2);
|
||||||
$this->assertEquals('<div class="row">' . PHP_EOL . '<p>Lorem ipsum dolor sit amet.</p>' . PHP_EOL . '</div>' . PHP_EOL, $result3);
|
$this->assertEquals('<div class="row"><p>Lorem ipsum dolor sit amet.</p></div>', $result3);
|
||||||
$this->assertEquals('<div class="row">' . PHP_EOL . '<img src="http://example.com/image1">' . PHP_EOL . '<img src="http://example.com/image2">' . PHP_EOL . '</div>' . PHP_EOL, $result4);
|
$this->assertEquals('<div class="row"><img src="http://example.com/image1"><img src="http://example.com/image2"></div>', $result4);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testMetaOpenGraph()
|
public function testMetaOpenGraph()
|
||||||
{
|
{
|
||||||
$result = $this->htmlBuilder->meta(null, 'website', ['property' => 'og:type']);
|
$result = $this->htmlBuilder->meta(null, 'website', ['property' => 'og:type']);
|
||||||
|
|
||||||
$this->assertEquals('<meta content="website" property="og:type">' . PHP_EOL, $result);
|
$this->assertEquals('<meta content="website" property="og:type">', $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFavicon()
|
public function testFavicon()
|
||||||
@@ -102,7 +102,7 @@ class HtmlBuilderTest extends PHPUnit_Framework_TestCase
|
|||||||
$target = $this->urlGenerator->to('bar.ico');
|
$target = $this->urlGenerator->to('bar.ico');
|
||||||
$result = $this->htmlBuilder->favicon('http://foo.com/bar.ico');
|
$result = $this->htmlBuilder->favicon('http://foo.com/bar.ico');
|
||||||
|
|
||||||
$this->assertEquals('<link rel="shortcut icon" type="image/x-icon" href="' . $target . '">' . PHP_EOL, $result);
|
$this->assertEquals('<link rel="shortcut icon" type="image/x-icon" href="' . $target . '">', $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testComponentRegistration()
|
public function testComponentRegistration()
|
||||||
@@ -118,8 +118,11 @@ class HtmlBuilderTest extends PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$result2 = $this->htmlBuilder->link("http://www.example.com", "<span>Example.com</span>", ["class" => "example-link"], null, false);
|
$result2 = $this->htmlBuilder->link("http://www.example.com", "<span>Example.com</span>", ["class" => "example-link"], null, false);
|
||||||
|
|
||||||
|
$result3 = $this->htmlBuilder->link("https://a.com/b?id=4¬_id=5", "URL which needs escaping");
|
||||||
|
|
||||||
$this->assertEquals('<a href="http://www.example.com" class="example-link"><span>Example.com</span></a>', $result1);
|
$this->assertEquals('<a href="http://www.example.com" class="example-link"><span>Example.com</span></a>', $result1);
|
||||||
$this->assertEquals('<a href="http://www.example.com" class="example-link"><span>Example.com</span></a>', $result2);
|
$this->assertEquals('<a href="http://www.example.com" class="example-link"><span>Example.com</span></a>', $result2);
|
||||||
|
$this->assertEquals('<a href="https://a.com/b?id=4&not_id=5">URL which needs escaping</a>', $result3);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testMailto()
|
public function testMailto()
|
||||||
|
|||||||
Reference in new issue
Block a user