Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Member Functions | Protected Attributes
Fieldset Class Reference
Inheritance diagram for Fieldset:
AbstractBlock RendererInterface AbstractBlock DataObject BlockInterface DisableOutput Expanded Group Payment Statuses Info

Public Member Functions

 __construct (\Magento\Backend\Block\Context $context, \Magento\Backend\Model\Auth\Session $authSession, \Magento\Framework\View\Helper\Js $jsHelper, array $data=[])
 
 render (AbstractElement $element)
 
- Public Member Functions inherited from AbstractBlock
 __construct (\Magento\Backend\Block\Context $context, array $data=[])
 
- 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

 _getChildrenElementsHtml (AbstractElement $element)
 
 _getHeaderHtml ($element)
 
 _getFrontendClass ($element)
 
 _getHeaderTitleHtml ($element)
 
 _getHeaderCommentHtml ($element)
 
 _getFooterHtml ($element)
 
 _getExtraJs ($element)
 
 _isCollapseState ($element)
 
- 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

 $_authSession
 
 $_jsHelper
 
 $isCollapsedDefault = false
 
- Protected Attributes inherited from AbstractBlock
 $_authorization
 
- 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 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

@api

Since
100.0.2

Definition at line 18 of file Fieldset.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( \Magento\Backend\Block\Context  $context,
\Magento\Backend\Model\Auth\Session  $authSession,
\Magento\Framework\View\Helper\Js  $jsHelper,
array  $data = [] 
)
Parameters
\Magento\Backend\Block\Context$context
\Magento\Backend\Model\Auth\Session$authSession
\Magento\Framework\View\Helper\Js$jsHelper
array$data

Definition at line 44 of file Fieldset.php.

49  {
50  $this->_jsHelper = $jsHelper;
51  $this->_authSession = $authSession;
52  parent::__construct($context, $data);
53  }

Member Function Documentation

◆ _getChildrenElementsHtml()

_getChildrenElementsHtml ( AbstractElement  $element)
protected
Parameters
AbstractElement$element
Returns
string
Since
100.1.0

Definition at line 78 of file Fieldset.php.

79  {
80  $elements = '';
81  foreach ($element->getElements() as $field) {
82  if ($field instanceof \Magento\Framework\Data\Form\Element\Fieldset) {
83  $elements .= '<tr id="row_' . $field->getHtmlId() . '">'
84  . '<td colspan="4">' . $field->toHtml() . '</td></tr>';
85  } else {
86  $elements .= $field->toHtml();
87  }
88  }
89 
90  return $elements;
91  }
$element
Definition: element.phtml:12

◆ _getExtraJs()

_getExtraJs (   $element)
protected

Return js code for fieldset:

  • observe fieldset rows;
  • apply collapse;
Parameters
AbstractElement$element
Returns
string

Definition at line 232 of file Fieldset.php.

233  {
234  $htmlId = $element->getHtmlId();
235  $output = "require(['prototype'], function(){Fieldset.applyCollapse('{$htmlId}');});";
236  return $this->_jsHelper->getScript($output);
237  }
$element
Definition: element.phtml:12

◆ _getFooterHtml()

_getFooterHtml (   $element)
protected

Return footer html for fieldset Add extra tooltip comments to elements

Parameters
AbstractElement$element
Returns
string

Definition at line 202 of file Fieldset.php.

203  {
204  $html = '</tbody></table>';
205  foreach ($element->getElements() as $field) {
206  if ($field->getTooltip()) {
207  $html .= sprintf(
208  '<div id="row_%s_comment" class="system-tooltip-box" style="display:none;">%s</div>',
209  $field->getId(),
210  $field->getTooltip()
211  );
212  }
213  }
214  $html .= '</fieldset>' . $this->_getExtraJs($element);
215 
216  if ($element->getIsNested()) {
217  $html .= '</td></tr>';
218  } else {
219  $html .= '</div>';
220  }
221  return $html;
222  }
$element
Definition: element.phtml:12

◆ _getFrontendClass()

_getFrontendClass (   $element)
protected

Get frontend class

Parameters
AbstractElement$element
Returns
string

Definition at line 144 of file Fieldset.php.

145  {
146  $group = $element->getGroup();
147  $cssClass = isset($group['fieldset_css']) ? $group['fieldset_css'] : '';
148  return 'section-config' . (empty($cssClass) ? '' : ' ' . $cssClass);
149  }
$group
Definition: sections.phtml:16
if(!isset($advancedLabel)) $cssClass
Definition: fieldset.phtml:25
$element
Definition: element.phtml:12

◆ _getHeaderCommentHtml()

_getHeaderCommentHtml (   $element)
protected

Return header comment part of html for fieldset

Parameters
AbstractElement$element
Returns
string

Definition at line 177 of file Fieldset.php.

178  {
179  return $element->getComment() ? '<div class="comment">' . $element->getComment() . '</div>' : '';
180  }
$element
Definition: element.phtml:12

◆ _getHeaderHtml()

_getHeaderHtml (   $element)
protected

Return header html for fieldset

Parameters
AbstractElement$element
Returns
string

Definition at line 99 of file Fieldset.php.

100  {
101  if ($element->getIsNested()) {
102  $html = '<tr class="nested"><td colspan="4"><div class="' . $this->_getFrontendClass($element) . '">';
103  } else {
104  $html = '<div class="' . $this->_getFrontendClass($element) . '">';
105  }
106 
107  $html .= '<div class="entry-edit-head admin__collapsible-block">' .
108  '<span id="' .
109  $element->getHtmlId() .
110  '-link" class="entry-edit-head-link"></span>';
111 
112  $html .= $this->_getHeaderTitleHtml($element);
113 
114  $html .= '</div>';
115  $html .= '<input id="' .
116  $element->getHtmlId() .
117  '-state" name="config_state[' .
118  $element->getId() .
119  ']" type="hidden" value="' .
120  (int)$this->_isCollapseState(
121  $element
122  ) . '" />';
123  $html .= '<fieldset class="' . $this->_getFieldsetCss() . '" id="' . $element->getHtmlId() . '">';
124  $html .= '<legend>' . $element->getLegend() . '</legend>';
125 
126  $html .= $this->_getHeaderCommentHtml($element);
127 
128  // field label column
129  $html .= '<table cellspacing="0" class="form-list"><colgroup class="label" /><colgroup class="value" />';
130  if ($this->getRequest()->getParam('website') || $this->getRequest()->getParam('store')) {
131  $html .= '<colgroup class="use-default" />';
132  }
133  $html .= '<colgroup class="scope-label" /><colgroup class="" /><tbody>';
134 
135  return $html;
136  }
$element
Definition: element.phtml:12

◆ _getHeaderTitleHtml()

_getHeaderTitleHtml (   $element)
protected

Return header title part of html for fieldset

Parameters
AbstractElement$element
Returns
string

Definition at line 157 of file Fieldset.php.

158  {
159  return '<a id="' .
160  $element->getHtmlId() .
161  '-head" href="#' .
162  $element->getHtmlId() .
163  '-link" onclick="Fieldset.toggleCollapse(\'' .
164  $element->getHtmlId() .
165  '\', \'' .
166  $this->getUrl(
167  '*/*/state'
168  ) . '\'); return false;">' . $element->getLegend() . '</a>';
169  }
$element
Definition: element.phtml:12

◆ _isCollapseState()

_isCollapseState (   $element)
protected

Collapsed or expanded fieldset when page loaded?

Parameters
AbstractElement$element
Returns
bool

Definition at line 245 of file Fieldset.php.

246  {
247  if ($element->getExpanded() ||
248  ($element->getForm() && $element->getForm()->getElements()->count() === 1)
249  ) {
250  return true;
251  }
252 
253  $extra = $this->_authSession->getUser()->getExtra();
254  if (isset($extra['configState'][$element->getId()])) {
255  return $extra['configState'][$element->getId()];
256  }
258  }
if( $_orders &&count( $_orders))( 'Orders') ?></caption >< thead >< tr >< th scopeforeach( $_orders as $_order)(__( 'Order #')) ?>" class $extra
Definition: history.phtml:32
$element
Definition: element.phtml:12

◆ render()

render ( AbstractElement  $element)

Render fieldset html

Parameters
AbstractElement$element
Returns
string

Definition at line 61 of file Fieldset.php.

62  {
63  $this->setElement($element);
64  $header = $this->_getHeaderHtml($element);
65 
66  $elements = $this->_getChildrenElementsHtml($element);
67 
68  $footer = $this->_getFooterHtml($element);
69 
70  return $header . $elements . $footer;
71  }
_getChildrenElementsHtml(AbstractElement $element)
Definition: Fieldset.php:78
$element
Definition: element.phtml:12

Field Documentation

◆ $_authSession

$_authSession
protected

Definition at line 24 of file Fieldset.php.

◆ $_jsHelper

$_jsHelper
protected

Definition at line 29 of file Fieldset.php.

◆ $isCollapsedDefault

$isCollapsedDefault = false
protected

Definition at line 36 of file Fieldset.php.


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