Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Member Functions | Protected Attributes
AbstractFieldArray Class Reference
Inheritance diagram for AbstractFieldArray:
Field Template RendererInterface Template AbstractBlock DataObject BlockInterface CountryCreditCard Minsaleqty FieldArray Regexceptions

Public Member Functions

 addColumn ($name, $params)
 
 renderCellTemplate ($columnName)
 
 isAddAfter ()
 
 getColumns ()
 
 getAddButtonLabel ()
 
- Public Member Functions inherited from Field
 render (\Magento\Framework\Data\Form\Element\AbstractElement $element)
 
- Public Member Functions inherited from Template
 __construct (\Magento\Backend\Block\Template\Context $context, array $data=[])
 
 getFormKey ()
 
 isOutputEnabled ($moduleName=null)
 
 getAuthorization ()
 
 getToolbar ()
 
- Public Member Functions inherited from Template
 __construct (Template\Context $context, array $data=[])
 
 setTemplateContext ($templateContext)
 
 getTemplate ()
 
 setTemplate ($template)
 
 getTemplateFile ($template=null)
 
 getArea ()
 
 assign ($key, $value=null)
 
 fetchView ($fileName)
 
 getBaseUrl ()
 
 getObjectData (\Magento\Framework\DataObject $object, $key)
 
 getCacheKeyInfo ()
 
- Public Member Functions inherited from AbstractBlock
 __construct (\Magento\Framework\View\Element\Context $context, array $data=[])
 
 getJsLayout ()
 
 getRequest ()
 
 getParentBlock ()
 
 setLayout (\Magento\Framework\View\LayoutInterface $layout)
 
 getLayout ()
 
 setNameInLayout ($name)
 
 getChildNames ()
 
 setAttribute ($name, $value=null)
 
 setChild ($alias, $block)
 
 addChild ($alias, $block, $data=[])
 
 unsetChild ($alias)
 
 unsetCallChild ($alias, $callback, $result, $params)
 
 unsetChildren ()
 
 getChildBlock ($alias)
 
 getChildHtml ($alias='', $useCache=true)
 
 getChildChildHtml ($alias, $childChildAlias='', $useCache=true)
 
 getBlockHtml ($name)
 
 insert ($element, $siblingName=0, $after=true, $alias='')
 
 append ($element, $alias='')
 
 getGroupChildNames ($groupName)
 
 getChildData ($alias, $key='')
 
 getUiId ($arg1=null, $arg2=null, $arg3=null, $arg4=null, $arg5=null)
 
 getJsId ($arg1=null, $arg2=null, $arg3=null, $arg4=null, $arg5=null)
 
 getUrl ($route='', $params=[])
 
 getViewFileUrl ($fileId, array $params=[])
 
 formatDate ( $date=null, $format=\IntlDateFormatter::SHORT, $showTime=false, $timezone=null)
 
 formatTime ( $time=null, $format=\IntlDateFormatter::SHORT, $showDate=false)
 
 getModuleName ()
 
 escapeHtml ($data, $allowedTags=null)
 
 escapeJs ($string)
 
 escapeHtmlAttr ($string, $escapeSingleQuote=true)
 
 escapeCss ($string)
 
 stripTags ($data, $allowableTags=null, $allowHtmlEntities=false)
 
 escapeUrl ($string)
 
 escapeXssInUrl ($data)
 
 escapeQuote ($data, $addSlashes=false)
 
 escapeJsQuote ($data, $quote='\'')
 
 getNameInLayout ()
 
 getCacheKeyInfo ()
 
 getCacheKey ()
 
 getVar ($name, $module=null)
 
 isScopePrivate ()
 
- Public Member Functions inherited from DataObject
 __construct (array $data=[])
 
 addData (array $arr)
 
 setData ($key, $value=null)
 
 unsetData ($key=null)
 
 getData ($key='', $index=null)
 
 getDataByPath ($path)
 
 getDataByKey ($key)
 
 setDataUsingMethod ($key, $args=[])
 
 getDataUsingMethod ($key, $args=null)
 
 hasData ($key='')
 
 toArray (array $keys=[])
 
 convertToArray (array $keys=[])
 
 toXml (array $keys=[], $rootName='item', $addOpenTag=false, $addCdata=true)
 
 convertToXml (array $arrAttributes=[], $rootName='item', $addOpenTag=false, $addCdata=true)
 
 toJson (array $keys=[])
 
 convertToJson (array $keys=[])
 
 toString ($format='')
 
 __call ($method, $args)
 
 isEmpty ()
 
 serialize ($keys=[], $valueSeparator='=', $fieldSeparator=' ', $quote='"')
 
 debug ($data=null, &$objects=[])
 
 offsetSet ($offset, $value)
 
 offsetExists ($offset)
 
 offsetUnset ($offset)
 
 offsetGet ($offset)
 
- Public Member Functions inherited from BlockInterface
 toHtml ()
 
- Public Member Functions inherited from RendererInterface
 render (\Magento\Framework\Data\Form\Element\AbstractElement $element)
 

Protected Member Functions

 _construct ()
 
 _getParam ($params, $paramName, $defaultValue=null)
 
 _getElementHtml (\Magento\Framework\Data\Form\Element\AbstractElement $element)
 
 _prepareArrayRow (\Magento\Framework\DataObject $row)
 
 _getCellInputElementId ($rowId, $columnName)
 
 _getCellInputElementName ($columnName)
 
 _prepareToRender ()
 
 _toHtml ()
 
- Protected Member Functions inherited from Field
 _getElementHtml (\Magento\Framework\Data\Form\Element\AbstractElement $element)
 
 _renderValue (\Magento\Framework\Data\Form\Element\AbstractElement $element)
 
 _renderInheritCheckbox (\Magento\Framework\Data\Form\Element\AbstractElement $element)
 
 _isInheritCheckboxRequired (\Magento\Framework\Data\Form\Element\AbstractElement $element)
 
 _getInheritCheckboxLabel (\Magento\Framework\Data\Form\Element\AbstractElement $element)
 
 _renderScopeLabel (\Magento\Framework\Data\Form\Element\AbstractElement $element)
 
 _renderHint (\Magento\Framework\Data\Form\Element\AbstractElement $element)
 
 _decorateRowHtml (\Magento\Framework\Data\Form\Element\AbstractElement $element, $html)
 
- Protected Member Functions inherited from Template
 _toHtml ()
 
- Protected Member Functions inherited from Template
 _construct ()
 
 _toHtml ()
 
 getRootDirectory ()
 
 getMediaDirectory ()
 
- Protected Member Functions inherited from AbstractBlock
 _construct ()
 
 _prepareLayout ()
 
 _beforeToHtml ()
 
 _afterToHtml ($html)
 
 _toHtml ()
 
 _getNotFoundUrl ($route='', $params=['_direct'=> 'core/index/notFound'])
 
 getCacheTags ()
 
 getCacheLifetime ()
 
 _loadCache ()
 
 _saveCache ($data)
 
 _getSidPlaceholder ($cacheKey=null)
 
- Protected Member Functions inherited from DataObject
 _getData ($key)
 
 _underscore ($name)
 

Protected Attributes

 $_columns = []
 
 $_addAfter = true
 
 $_addButtonLabel
 
 $_isPreparedToRender = false
 
 $_template = 'Magento_Config::system/config/form/field/array.phtml'
 
- Protected Attributes inherited from Template
 $_authorization
 
 $mathRandom
 
 $_backendSession
 
 $formKey
 
 $nameBuilder
 
- Protected Attributes inherited from Template
 $_viewVars = []
 
 $_baseUrl
 
 $_jsUrl
 
 $_allowSymlinks
 
 $_filesystem
 
 $_template
 
 $templateEnginePool
 
 $_storeManager
 
 $_appState
 
 $directory
 
 $templateContext
 
 $pageConfig
 
 $resolver
 
 $validator
 
- Protected Attributes inherited from AbstractBlock
 $_design
 
 $_session
 
 $_sidResolver
 
 $_nameInLayout
 
 $_layout
 
 $jsLayout = []
 
 $_request
 
 $_urlBuilder
 
 $_eventManager
 
 $_frontController
 
 $_assetRepo
 
 $_viewConfig
 
 $_cacheState
 
 $_logger
 
 $_escaper
 
 $filterManager
 
 $_localeDate
 
 $inlineTranslation
 
 $_isScopePrivate = false
 
 $_scopeConfig
 
 $_cache
 
- Protected Attributes inherited from DataObject
 $_data = []
 

Additional Inherited Members

- Static Public Member Functions inherited from AbstractBlock
static extractModuleName ($className)
 
- Data Fields inherited from Template
const XML_PATH_TEMPLATE_ALLOW_SYMLINK = 'dev/template/allow_symlink'
 
- Data Fields inherited from AbstractBlock
const CACHE_GROUP = \Magento\Framework\App\Cache\Type\Block::TYPE_IDENTIFIER
 
const CACHE_KEY_PREFIX = 'BLOCK_'
 
- Static Protected Attributes inherited from DataObject
static $_underscoreCache = []
 

Detailed Description

Backend system config array field renderer

Author
Magento Core Team core@.nosp@m.mage.nosp@m.ntoco.nosp@m.mmer.nosp@m.ce.co.nosp@m.m @api
Since
100.0.2

Definition at line 16 of file AbstractFieldArray.php.

Member Function Documentation

◆ _construct()

_construct ( )
protected

Check if columns are defined, set template

Returns
void

Definition at line 63 of file AbstractFieldArray.php.

64  {
65  if (!$this->_addButtonLabel) {
66  $this->_addButtonLabel = __('Add');
67  }
68  parent::_construct();
69  }
__()
Definition: __.php:13

◆ _getCellInputElementId()

_getCellInputElementId (   $rowId,
  $columnName 
)
protected

Get name for cell element

Parameters
string$rowId
string$columnName
Returns
string

Definition at line 173 of file AbstractFieldArray.php.

174  {
175  return $rowId . '_' . $columnName;
176  }

◆ _getCellInputElementName()

_getCellInputElementName (   $columnName)
protected

Get id for cell element

Parameters
string$columnName
Returns
string

Definition at line 184 of file AbstractFieldArray.php.

185  {
186  return $this->getElement()->getName() . '[<%- _id %>][' . $columnName . ']';
187  }

◆ _getElementHtml()

_getElementHtml ( \Magento\Framework\Data\Form\Element\AbstractElement  $element)
protected

Get the grid and scripts contents

Parameters
\Magento\Framework\Data\Form\Element\AbstractElement$element
Returns
string

Definition at line 113 of file AbstractFieldArray.php.

114  {
115  $this->setElement($element);
116  $html = $this->_toHtml();
117  $this->_arrayRowsCache = null;
118  // doh, the object is used as singleton!
119  return $html;
120  }
$element
Definition: element.phtml:12

◆ _getParam()

_getParam (   $params,
  $paramName,
  $defaultValue = null 
)
protected

Retrieve param

Parameters
array$params
string$paramName
string | bool$defaultValue
Returns
string|bool

Definition at line 102 of file AbstractFieldArray.php.

103  {
104  return empty($params[$paramName]) ? $defaultValue : $params[$paramName];
105  }
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
Definition: website.php:18

◆ _prepareArrayRow()

_prepareArrayRow ( \Magento\Framework\DataObject  $row)
protected

Prepare existing row data object

Parameters
\Magento\Framework\DataObject$row
Returns
void @SuppressWarnings(PHPMD.UnusedFormalParameter)

Definition at line 129 of file AbstractFieldArray.php.

130  {
131  // override in descendants
132  }

◆ _prepareToRender()

_prepareToRender ( )
protected

Prepare to render

Returns
void

Definition at line 240 of file AbstractFieldArray.php.

241  {
242  // Override in descendants to add columns, change add button label etc
243  }

◆ _toHtml()

_toHtml ( )
protected

Render block HTML

Returns
string
Exceptions

Definition at line 251 of file AbstractFieldArray.php.

252  {
253  if (!$this->_isPreparedToRender) {
254  $this->_prepareToRender();
255  $this->_isPreparedToRender = true;
256  }
257  if (empty($this->_columns)) {
258  throw new \Exception('At least one column must be defined.');
259  }
260  return parent::_toHtml();
261  }

◆ addColumn()

addColumn (   $name,
  $params 
)

Add a column to array-grid

Parameters
string$name
array$params
Returns
void

Definition at line 78 of file AbstractFieldArray.php.

79  {
80  $this->_columns[$name] = [
81  'label' => $this->_getParam($params, 'label', 'Column'),
82  'size' => $this->_getParam($params, 'size', false),
83  'style' => $this->_getParam($params, 'style'),
84  'class' => $this->_getParam($params, 'class'),
85  'renderer' => false,
86  ];
87  if (!empty($params['renderer'])
88  && $params['renderer'] instanceof \Magento\Framework\View\Element\AbstractBlock
89  ) {
90  $this->_columns[$name]['renderer'] = $params['renderer'];
91  }
92  }
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
Definition: website.php:18
if(!isset($_GET['name'])) $name
Definition: log.php:14

◆ getAddButtonLabel()

getAddButtonLabel ( )
Returns
string
Since
101.0.0

Definition at line 287 of file AbstractFieldArray.php.

◆ getColumns()

getColumns ( )

Returns columns array

Returns
array

Definition at line 278 of file AbstractFieldArray.php.

◆ isAddAfter()

isAddAfter ( )

Returns true if the addAfter directive is set

Returns
bool

Definition at line 268 of file AbstractFieldArray.php.

◆ renderCellTemplate()

renderCellTemplate (   $columnName)

Render array cell for prototypeJS template

Parameters
string$columnName
Returns
string
Exceptions

Definition at line 196 of file AbstractFieldArray.php.

197  {
198  if (empty($this->_columns[$columnName])) {
199  throw new \Exception('Wrong column name specified.');
200  }
201  $column = $this->_columns[$columnName];
202  $inputName = $this->_getCellInputElementName($columnName);
203 
204  if ($column['renderer']) {
205  return $column['renderer']->setInputName(
206  $inputName
207  )->setInputId(
208  $this->_getCellInputElementId('<%- _id %>', $columnName)
209  )->setColumnName(
210  $columnName
211  )->setColumn(
212  $column
213  )->toHtml();
214  }
215 
216  return '<input type="text" id="' . $this->_getCellInputElementId(
217  '<%- _id %>',
218  $columnName
219  ) .
220  '"' .
221  ' name="' .
222  $inputName .
223  '" value="<%- ' .
224  $columnName .
225  ' %>" ' .
226  ($column['size'] ? 'size="' .
227  $column['size'] .
228  '"' : '') .
229  ' class="' .
230  (isset($column['class'])
231  ? $column['class']
232  : 'input-text') . '"' . (isset($column['style']) ? ' style="' . $column['style'] . '"' : '') . '/>';
233  }

Field Documentation

◆ $_addAfter

$_addAfter = true
protected

Definition at line 30 of file AbstractFieldArray.php.

◆ $_addButtonLabel

$_addButtonLabel
protected

Definition at line 37 of file AbstractFieldArray.php.

◆ $_columns

$_columns = []
protected

Definition at line 23 of file AbstractFieldArray.php.

◆ $_isPreparedToRender

$_isPreparedToRender = false
protected

Definition at line 51 of file AbstractFieldArray.php.

◆ $_template

$_template = 'Magento_Config::system/config/form/field/array.phtml'
protected

Definition at line 56 of file AbstractFieldArray.php.


The documentation for this class was generated from the following file: