Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
d8776af5
Commit
d8776af5
authored
Nov 23, 2014
by
alexpott
Browse files
Issue
#2380391
by webflo: Fix storage settings for TextLongItem and StringLongItem
parent
826245d5
Changes
2
Hide whitespace changes
Inline
Side-by-side
core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringItem.php
View file @
d8776af5
...
...
@@ -91,14 +91,21 @@ public function getConstraints() {
public
static
function
generateSampleValue
(
FieldDefinitionInterface
$field_definition
)
{
$random
=
new
Random
();
$max
=
$field_definition
->
getSetting
(
'max_length'
);
$values
[
'value'
]
=
$random
->
word
(
mt_rand
(
1
,
$max
));
if
(
$max
)
{
$values
[
'value'
]
=
$random
->
word
(
mt_rand
(
1
,
$max
));
}
else
{
$values
[
'value'
]
=
$random
->
paragraphs
();
}
return
$values
;
}
/**
* {@inheritdoc}
*/
public
function
settingsForm
(
array
&
$form
,
FormStateInterface
$form_state
,
$has_data
)
{
public
function
s
torageS
ettingsForm
(
array
&
$form
,
FormStateInterface
$form_state
,
$has_data
)
{
$element
=
array
();
$element
[
'max_length'
]
=
array
(
...
...
core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringLongItem.php
View file @
d8776af5
...
...
@@ -8,6 +8,7 @@
namespace
Drupal\Core\Field\Plugin\Field\FieldType
;
use
Drupal\Core\Field\FieldStorageDefinitionInterface
;
use
Drupal\Core\Form\FormStateInterface
;
/**
* Defines the 'string_long' field type.
...
...
@@ -22,6 +23,15 @@
*/
class
StringLongItem
extends
StringItem
{
/**
* {@inheritdoc}
*/
public
static
function
defaultStorageSettings
()
{
$settings
=
parent
::
defaultStorageSettings
();
unset
(
$settings
[
'max_length'
]);
return
$settings
;
}
/**
* {@inheritdoc}
*/
...
...
@@ -36,4 +46,13 @@ public static function schema(FieldStorageDefinitionInterface $field_definition)
);
}
/**
* {@inheritdoc}
*/
public
function
storageSettingsForm
(
array
&
$form
,
FormStateInterface
$form_state
,
$has_data
)
{
$element
=
parent
::
storageSettingsForm
(
$form
,
$form_state
,
$has_data
);
unset
(
$element
[
'max_length'
]);
return
$element
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment