Issue #2380391 by webflo: Fix storage settings for TextLongItem and StringLongItem
parent
826245d509
commit
d8776af599
|
@ -91,14 +91,21 @@ class StringItem extends FieldItemBase {
|
||||||
public static function generateSampleValue(FieldDefinitionInterface $field_definition) {
|
public static function generateSampleValue(FieldDefinitionInterface $field_definition) {
|
||||||
$random = new Random();
|
$random = new Random();
|
||||||
$max = $field_definition->getSetting('max_length');
|
$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;
|
return $values;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function settingsForm(array &$form, FormStateInterface $form_state, $has_data) {
|
public function storageSettingsForm(array &$form, FormStateInterface $form_state, $has_data) {
|
||||||
$element = array();
|
$element = array();
|
||||||
|
|
||||||
$element['max_length'] = array(
|
$element['max_length'] = array(
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
namespace Drupal\Core\Field\Plugin\Field\FieldType;
|
namespace Drupal\Core\Field\Plugin\Field\FieldType;
|
||||||
|
|
||||||
use Drupal\Core\Field\FieldStorageDefinitionInterface;
|
use Drupal\Core\Field\FieldStorageDefinitionInterface;
|
||||||
|
use Drupal\Core\Form\FormStateInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines the 'string_long' field type.
|
* Defines the 'string_long' field type.
|
||||||
|
@ -22,6 +23,15 @@ use Drupal\Core\Field\FieldStorageDefinitionInterface;
|
||||||
*/
|
*/
|
||||||
class StringLongItem extends StringItem {
|
class StringLongItem extends StringItem {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public static function defaultStorageSettings() {
|
||||||
|
$settings = parent::defaultStorageSettings();
|
||||||
|
unset($settings['max_length']);
|
||||||
|
return $settings;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
@ -36,4 +46,13 @@ class StringLongItem extends StringItem {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue