Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes
Container Class Reference
Inheritance diagram for Container:
Container Template ContainerInterface Template ContextInterface AbstractBlock DataObject BlockInterface Edit Delete Edit Edit Edit Edit Edit Edit Edit Edit Edit View Details Add Edit Edit Address Create Create View Create View Assign NewStatus View Edit Create View Edit Edit Edit Edit Edit Edit

Public Member Functions

 getBackUrl ()
 
 getDeleteUrl ()
 
 getSaveUrl ()
 
 getFormActionUrl ()
 
 getFormHtml ()
 
 getFormInitScripts ()
 
 getFormScripts ()
 
 getHeaderWidth ()
 
 getHeaderCssClass ()
 
 getHeaderHtml ()
 
 setDataObject ($object)
 
- Public Member Functions inherited from Container
 __construct (\Magento\Backend\Block\Widget\Context $context, array $data=[])
 
 addButton ($buttonId, $data, $level=0, $sortOrder=0, $region='toolbar')
 
 removeButton ($buttonId)
 
 updateButton ($buttonId, $key, $data)
 
 getHeaderText ()
 
 getHeaderCssClass ()
 
 getHeaderHtml ()
 
 hasFooterButtons ()
 
 canRender (Button\Item $item)
 
- 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 ContextInterface
 canRender (\Magento\Backend\Block\Widget\Button\Item $item)
 

Data Fields

const PARAM_BLOCK_GROUP = 'block_group'
 
const PARAM_MODE = 'mode'
 
- Data Fields inherited from Container
const PARAM_CONTROLLER = 'controller'
 
const PARAM_HEADER_TEXT = 'header_text'
 
- 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_'
 

Protected Member Functions

 _construct ()
 
 _prepareLayout ()
 
 _buildFormClassName ()
 
- Protected Member Functions inherited from Container
 _construct ()
 
 _prepareLayout ()
 
- 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

 $_objectId = 'id'
 
 $_formScripts = []
 
 $_formInitScripts = []
 
 $_mode = 'edit'
 
 $_blockGroup = 'Magento_Backend'
 
 $_template = 'Magento_Backend::widget/form/container.phtml'
 
- Protected Attributes inherited from Container
 $_controller = 'empty'
 
 $_headerText = 'Container Widget Header'
 
 $buttonList
 
 $toolbar
 
- 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)
 
- Static Protected Attributes inherited from DataObject
static $_underscoreCache = []
 

Detailed Description

Backend form container block

@api

Deprecated:
100.2.0 in favour of UI component implementation @SuppressWarnings(PHPMD.NumberOfChildren)
Since
100.0.2

Definition at line 16 of file Container.php.

Member Function Documentation

◆ _buildFormClassName()

_buildFormClassName ( )
protected

Build child form class name

Returns
string

Definition at line 136 of file Container.php.

137  {
138  return $this->nameBuilder->buildClassName(
139  [$this->_blockGroup, 'Block', $this->_controller, $this->_mode, 'Form']
140  );
141  }

◆ _construct()

_construct ( )
protected
Returns
void

Definition at line 61 of file Container.php.

62  {
63  parent::_construct();
64  if ($this->hasData(self::PARAM_BLOCK_GROUP)) {
65  $this->_blockGroup = $this->_getData(self::PARAM_BLOCK_GROUP);
66  }
67  if ($this->hasData(self::PARAM_MODE)) {
68  $this->_mode = $this->_getData(self::PARAM_MODE);
69  }
70 
71  $this->addButton(
72  'back',
73  [
74  'label' => __('Back'),
75  'onclick' => 'setLocation(\'' . $this->getBackUrl() . '\')',
76  'class' => 'back'
77  ],
78  -1
79  );
80  $this->addButton(
81  'reset',
82  ['label' => __('Reset'), 'onclick' => 'setLocation(window.location.href)', 'class' => 'reset'],
83  -1
84  );
85 
86  $objId = $this->getRequest()->getParam($this->_objectId);
87 
88  if (!empty($objId)) {
89  $this->addButton(
90  'delete',
91  [
92  'label' => __('Delete'),
93  'class' => 'delete',
94  'onclick' => 'deleteConfirm(\'' . __(
95  'Are you sure you want to do this?'
96  ) . '\', \'' . $this->getDeleteUrl() . '\', {data: {}})'
97  ]
98  );
99  }
100 
101  $this->addButton(
102  'save',
103  [
104  'label' => __('Save'),
105  'class' => 'save primary',
106  'data_attribute' => [
107  'mage-init' => ['button' => ['event' => 'save', 'target' => '#edit_form']],
108  ]
109  ],
110  1
111  );
112  }
if( $form)() ?>< script > require(['jquery' mage mage
Definition: save.phtml:15
__()
Definition: __.php:13
addButton($buttonId, $data, $level=0, $sortOrder=0, $region='toolbar')
Definition: Container.php:85

◆ _prepareLayout()

_prepareLayout ( )
protected

Create form block

Returns
$this

Definition at line 119 of file Container.php.

120  {
121  if ($this->_blockGroup && $this->_controller && $this->_mode && !$this->_layout->getChildName(
122  $this->_nameInLayout,
123  'form'
124  )
125  ) {
126  $this->addChild('form', $this->_buildFormClassName());
127  }
128  return parent::_prepareLayout();
129  }

◆ getBackUrl()

getBackUrl ( )

Get URL for back (reset) button

Returns
string

Definition at line 148 of file Container.php.

149  {
150  return $this->getUrl('*/*/');
151  }

◆ getDeleteUrl()

getDeleteUrl ( )
Returns
string

Definition at line 156 of file Container.php.

157  {
158  return $this->getUrl('*/*/delete', [$this->_objectId => $this->getRequest()->getParam($this->_objectId)]);
159  }

◆ getFormActionUrl()

getFormActionUrl ( )

Get form action URL

Returns
string

Definition at line 177 of file Container.php.

178  {
179  if ($this->hasFormActionUrl()) {
180  return $this->getData('form_action_url');
181  }
182  return $this->getUrl('*/*/save');
183  }
getData($key='', $index=null)
Definition: DataObject.php:119

◆ getFormHtml()

getFormHtml ( )
Returns
string

Definition at line 188 of file Container.php.

189  {
190  $this->getChildBlock('form')->setData('action', $this->getSaveUrl());
191  return $this->getChildHtml('form');
192  }

◆ getFormInitScripts()

getFormInitScripts ( )
Returns
string

Definition at line 197 of file Container.php.

198  {
199  if (!empty($this->_formInitScripts) && is_array($this->_formInitScripts)) {
200  return '<script>' . implode("\n", $this->_formInitScripts) . '</script>';
201  }
202  return '';
203  }

◆ getFormScripts()

getFormScripts ( )
Returns
string

Definition at line 208 of file Container.php.

209  {
210  if (!empty($this->_formScripts) && is_array($this->_formScripts)) {
211  return '<script>' . implode("\n", $this->_formScripts) . '</script>';
212  }
213  return '';
214  }

◆ getHeaderCssClass()

getHeaderCssClass ( )
Returns
string

Definition at line 227 of file Container.php.

228  {
229  return 'icon-head head-' . strtr($this->_controller, '_', '-');
230  }

◆ getHeaderHtml()

getHeaderHtml ( )
Returns
string

Definition at line 235 of file Container.php.

236  {
237  return '<h3 class="' . $this->getHeaderCssClass() . '">' . $this->getHeaderText() . '</h3>';
238  }

◆ getHeaderWidth()

getHeaderWidth ( )
Returns
string

Definition at line 219 of file Container.php.

220  {
221  return '';
222  }

◆ getSaveUrl()

getSaveUrl ( )

Get form save URL

See also
getFormActionUrl()
Returns
string

Definition at line 167 of file Container.php.

168  {
169  return $this->getFormActionUrl();
170  }

◆ setDataObject()

setDataObject (   $object)

Set data object and pass it to form

Parameters
\Magento\Framework\DataObject$object
Returns
$this

Definition at line 246 of file Container.php.

247  {
248  $this->getChildBlock('form')->setDataObject($object);
249  return $this->setData('data_object', $object);
250  }
setData($key, $value=null)
Definition: DataObject.php:72

Field Documentation

◆ $_blockGroup

$_blockGroup = 'Magento_Backend'
protected

Definition at line 41 of file Container.php.

◆ $_formInitScripts

$_formInitScripts = []
protected

Definition at line 31 of file Container.php.

◆ $_formScripts

$_formScripts = []
protected

Definition at line 26 of file Container.php.

◆ $_mode

$_mode = 'edit'
protected

Definition at line 36 of file Container.php.

◆ $_objectId

$_objectId = 'id'
protected

Definition at line 21 of file Container.php.

◆ $_template

$_template = 'Magento_Backend::widget/form/container.phtml'
protected

Definition at line 56 of file Container.php.

◆ PARAM_BLOCK_GROUP

const PARAM_BLOCK_GROUP = 'block_group'

Definition at line 46 of file Container.php.

◆ PARAM_MODE

const PARAM_MODE = 'mode'

Definition at line 51 of file Container.php.


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