public FieldItemList::generateSampleItems($count = 1)
Populates a specified number of field items with valid sample data.
int $count: The number of items to create.
Overrides FieldItemListInterface::generateSampleItems
public function generateSampleItems($count = 1) { $field_definition = $this->getFieldDefinition(); $field_type_class = \Drupal::service('plugin.manager.field.field_type')->getPluginClass($field_definition->getType()); for ($delta = 0; $delta < $count; $delta++) { $values[$delta] = $field_type_class::generateSampleValue($field_definition); } $this->setValue($values); }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Field!FieldItemList.php/function/FieldItemList::generateSampleItems/8.1.x