Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
41cd9291a6 | ||
|
|
818efc2e16 | ||
|
|
e6496328af | ||
|
|
137a2efcf1 | ||
|
|
32c27a54cd | ||
|
|
f9deb1da6f | ||
|
|
5feb06537d | ||
|
|
e1318fcfdd | ||
|
|
cecb65626c | ||
|
|
a5f7464ee6 | ||
|
|
cd71ed1538 | ||
|
|
2dfc110b6c | ||
|
|
8997f1209d | ||
|
|
b4c0a3e26d | ||
|
|
1810274c8a | ||
|
|
f380cdc14d | ||
|
|
0ac9642ebb | ||
|
|
b9322c703d |
No files matched your search
+1
-1
@@ -1,8 +1,8 @@
|
|||||||
language: php
|
language: php
|
||||||
|
|
||||||
php:
|
php:
|
||||||
- 7.0
|
|
||||||
- 7.1
|
- 7.1
|
||||||
|
- 7.2
|
||||||
|
|
||||||
sudo: false
|
sudo: false
|
||||||
|
|
||||||
|
|||||||
+9
-9
@@ -18,16 +18,16 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=7.0.0",
|
"php": ">=7.1.3",
|
||||||
"illuminate/http": "5.5.*",
|
"illuminate/http": "5.6.*",
|
||||||
"illuminate/routing": "5.5.*",
|
"illuminate/routing": "5.6.*",
|
||||||
"illuminate/session": "5.5.*",
|
"illuminate/session": "5.6.*",
|
||||||
"illuminate/support": "5.5.*",
|
"illuminate/support": "5.6.*",
|
||||||
"illuminate/view": "5.5.*"
|
"illuminate/view": "5.6.*"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"illuminate/database": "5.5.*",
|
"illuminate/database": "5.6.*",
|
||||||
"mockery/mockery": "~0.9.4",
|
"mockery/mockery": "~1.0",
|
||||||
"phpunit/phpunit": "~5.4"
|
"phpunit/phpunit": "~5.4"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
@@ -40,7 +40,7 @@
|
|||||||
},
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "5.5-dev"
|
"dev-master": "5.6-dev"
|
||||||
},
|
},
|
||||||
"laravel": {
|
"laravel": {
|
||||||
"providers": [
|
"providers": [
|
||||||
|
|||||||
@@ -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,7 +81,7 @@ 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);
|
||||||
|
|
||||||
|
|||||||
+14
-11
@@ -527,7 +527,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>');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -709,20 +709,23 @@ class FormBuilder
|
|||||||
* @param string $selected
|
* @param string $selected
|
||||||
* @param array $attributes
|
* @param array $attributes
|
||||||
* @param array $optionsAttributes
|
* @param array $optionsAttributes
|
||||||
|
* @param integer $level
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Support\HtmlString
|
* @return \Illuminate\Support\HtmlString
|
||||||
*/
|
*/
|
||||||
protected function optionGroup($list, $label, $selected, array $attributes = [], array $optionsAttributes = [])
|
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) {
|
||||||
$optionAttributes = $optionsAttributes[$value] ?? [];
|
$optionAttributes = $optionsAttributes[$value] ?? [];
|
||||||
|
if (is_array($display)) {
|
||||||
$html[] = $this->option($display, $value, $selected, $optionAttributes);
|
$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($label) . '"' . $this->html->attributes($attributes) . '>' . implode('', $html) . '</optgroup>');
|
return $this->toHtmlString('<optgroup label="' . e($space.$label, false) . '"' . $this->html->attributes($attributes) . '>' . implode('', $html) . '</optgroup>');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -743,7 +746,7 @@ class FormBuilder
|
|||||||
|
|
||||||
$string = '<option' . $this->html->attributes($options) . '>';
|
$string = '<option' . $this->html->attributes($options) . '>';
|
||||||
if ($display !== null) {
|
if ($display !== null) {
|
||||||
$string .= e($display) . '</option>';
|
$string .= e($display, false) . '</option>';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->toHtmlString($string);
|
return $this->toHtmlString($string);
|
||||||
@@ -766,7 +769,7 @@ class FormBuilder
|
|||||||
'value' => '',
|
'value' => '',
|
||||||
];
|
];
|
||||||
|
|
||||||
return $this->toHtmlString('<option' . $this->html->attributes($options) . '>' . e($display) . '</option>');
|
return $this->toHtmlString('<option' . $this->html->attributes($options) . ' hidden="hidden">' . e($display, false) . '</option>');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1183,7 +1186,7 @@ class FormBuilder
|
|||||||
}
|
}
|
||||||
|
|
||||||
$request = $this->request($name);
|
$request = $this->request($name);
|
||||||
if (! is_null($request) && $name !== '_method') {
|
if (! is_null($request) && $name != '_method') {
|
||||||
return $request;
|
return $request;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1267,7 +1270,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+2
-2
@@ -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>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -456,7 +456,7 @@ class HtmlBuilder
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (! is_null($value)) {
|
if (! is_null($value)) {
|
||||||
return $key . '="' . e($value) . '"';
|
return $key . '="' . e($value, false) . '"';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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()
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -467,7 +467,7 @@ class FormBuilderTest extends PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$select = $this->formBuilder->select('avc', [1 => 'Yes', 0 => 'No'], true, ['placeholder' => 'Select']);
|
$select = $this->formBuilder->select('avc', [1 => 'Yes', 0 => 'No'], true, ['placeholder' => 'Select']);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'<select name="avc"><option value="">Select</option><option value="1" selected>Yes</option><option value="0" >No</option></select>',
|
'<select name="avc"><option value="" hidden="hidden">Select</option><option value="1" selected>Yes</option><option value="0" >No</option></select>',
|
||||||
$select
|
$select
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -516,7 +516,7 @@ class FormBuilderTest extends PHPUnit_Framework_TestCase
|
|||||||
['placeholder' => 'Select One...']
|
['placeholder' => 'Select One...']
|
||||||
);
|
);
|
||||||
$this->assertEquals($select,
|
$this->assertEquals($select,
|
||||||
'<select name="size"><option selected="selected" value="">Select One...</option><option value="L">Large</option><option value="S">Small</option></select>');
|
'<select name="size"><option selected="selected" value="" hidden="hidden">Select One...</option><option value="L">Large</option><option value="S">Small</option></select>');
|
||||||
|
|
||||||
$select = $this->formBuilder->select(
|
$select = $this->formBuilder->select(
|
||||||
'size',
|
'size',
|
||||||
@@ -525,7 +525,7 @@ class FormBuilderTest extends PHPUnit_Framework_TestCase
|
|||||||
['placeholder' => 'Select One...']
|
['placeholder' => 'Select One...']
|
||||||
);
|
);
|
||||||
$this->assertEquals($select,
|
$this->assertEquals($select,
|
||||||
'<select name="size"><option value="">Select One...</option><option value="L" selected="selected">Large</option><option value="S">Small</option></select>');
|
'<select name="size"><option value="" hidden="hidden">Select One...</option><option value="L" selected="selected">Large</option><option value="S">Small</option></select>');
|
||||||
|
|
||||||
$select = $this->formBuilder->select(
|
$select = $this->formBuilder->select(
|
||||||
'encoded_html',
|
'encoded_html',
|
||||||
@@ -534,7 +534,7 @@ class FormBuilderTest extends PHPUnit_Framework_TestCase
|
|||||||
['placeholder' => 'Select the ']
|
['placeholder' => 'Select the ']
|
||||||
);
|
);
|
||||||
$this->assertEquals($select,
|
$this->assertEquals($select,
|
||||||
'<select name="encoded_html"><option selected="selected" value="">Select the </option><option value="no_break_space"> </option><option value="ampersand">&</option><option value="lower_than"><</option></select>'
|
'<select name="encoded_html"><option selected="selected" value="" hidden="hidden">Select the </option><option value="no_break_space"> </option><option value="ampersand">&</option><option value="lower_than"><</option></select>'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user