Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Multiline.php
Go to the documentation of this file.
1 <?php
7 
12 
18 {
19  const NAME = 'multiline';
20 
21  const FORM_ELEMENT = 'input';
22 
23  const DATA_TYPE = 'text';
24 
31 
40  public function __construct(
43  array $components = [],
44  array $data = []
45  ) {
46  $this->uiComponentFactory = $uiComponentFactory;
47  parent::__construct($context, $components, $data);
48  }
49 
55  public function getComponentName()
56  {
57  return static::NAME;
58  }
59 
65  public function prepare()
66  {
67  $size = abs((int) $this->getData('config/size'));
68  $validation = [$this->getData('config/validation')];
69  while ($size--) {
70  $identifier = $this->getName() . '_' . $size;
71  $arguments = [
72  'data' => [
73  'name' => $identifier,
74  'config' => [
75  'dataScope' => $size,
76  'dataType' => static::DATA_TYPE,
77  'formElement' => static::FORM_ELEMENT,
78  'sortOrder' => $size,
79  ]
80  ]
81  ];
82 
83  if (!empty($validation[$size])) {
84  $arguments['data']['config']['validation'] = $validation[$size];
85  }
86 
87  $component = $this->uiComponentFactory->create($identifier, Field::NAME, $arguments);
88  $component->prepare();
89 
90  $this->components[$identifier] = $component;
91  }
92  parent::prepare();
93  }
94 }
__construct(ContextInterface $context, UiComponentFactory $uiComponentFactory, array $components=[], array $data=[])
Definition: Multiline.php:40
$arguments