当前位置: 首页>>代码示例>>PHP>>正文


PHP Form::addField方法代码示例

本文整理汇总了PHP中Magento\Framework\Data\Form::addField方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::addField方法的具体用法?PHP Form::addField怎么用?PHP Form::addField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Framework\Data\Form的用法示例。


在下文中一共展示了Form::addField方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * @param ContextInterface $context
  * @param FormFactory $formFactory
  * @param ConfigInterface $wysiwygConfig
  * @param array $components
  * @param array $data
  * @param array $config
  */
 public function __construct(ContextInterface $context, FormFactory $formFactory, ConfigInterface $wysiwygConfig, array $components = [], array $data = [], array $config = [])
 {
     $wysiwygConfigData = isset($config['wysiwygConfigData']) ? $config['wysiwygConfigData'] : [];
     $this->form = $formFactory->create();
     $this->editor = $this->form->addField($context->getNamespace() . '_' . $data['name'], 'Magento\\Framework\\Data\\Form\\Element\\Editor', ['force_load' => true, 'rows' => 20, 'name' => $data['name'], 'config' => $wysiwygConfig->getConfig($wysiwygConfigData), 'wysiwyg' => isset($config['wysiwyg']) ? $config['wysiwyg'] : null]);
     $data['config']['content'] = $this->editor->getElementHtml();
     parent::__construct($context, $components, $data);
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:16,代码来源:Wysiwyg.php

示例2: _initFormElements

 /**
  * Initialize form elements
  *
  * @param Configuration $controlsConfig
  * @param Form $form
  * @return $this
  */
 protected function _initFormElements($controlsConfig, $form)
 {
     $hintMessage = __('Please enter values for height and width.' . ' Use the chain icon if you want height and width to match.' . ' Be sure to see how it looks in your store.' . ' You may need to update your custom CSS file.');
     $form->addField('information_hint', 'note', ['after_element_html' => '<p class="note">' . $hintMessage . '</p>']);
     $whiteBorder = $controlsConfig->getControlData('product_image_border');
     if ($whiteBorder) {
         $this->_addWhiteBorderElement($whiteBorder);
     }
     $controls = $controlsConfig->getAllControlsData();
     foreach ($controls as $name => $control) {
         if ($control['type'] != 'image-sizing') {
             continue;
         }
         $this->_addImageSizeFieldset($name, $control);
     }
     $fieldset = $form->addFieldset('save_image_sizing_fieldset', ['name' => 'save_image_sizing_fieldset', 'fieldset_type' => 'field', 'class' => 'save_image_sizing']);
     $this->_addElementTypes($fieldset);
     if ($whiteBorder || $controls) {
         $fieldset->addField('save_image_sizing', 'button_button', ['name' => 'save_image_sizing', 'title' => __('Update'), 'value' => __('Update'), 'data-mage-init' => $this->escapeHtml(json_encode(['button' => ['event' => 'saveForm', 'target' => 'body']]))]);
     }
     return $this;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:29,代码来源:ImageSizing.php

示例3: _initColumns

 /**
  * Add column elements to form
  *
  * @param Form $form
  * @param string $tab
  * @return array
  */
 protected function _initColumns($form, $tab)
 {
     /** @var $columnLeft \Magento\DesignEditor\Block\Adminhtml\Editor\Form\Element\Column */
     $columnLeft = $form->addField('column-left-' . $tab, 'column', []);
     $columnLeft->setRendererFactory($this->_rendererFactory)->setElementsFactory($this->_elementsFactory);
     /** @var $columnMiddle \Magento\DesignEditor\Block\Adminhtml\Editor\Form\Element\Column */
     $columnMiddle = $form->addField('column-middle-' . $tab, 'column', []);
     $columnMiddle->setRendererFactory($this->_rendererFactory)->setElementsFactory($this->_elementsFactory);
     /** @var $columnRight \Magento\DesignEditor\Block\Adminhtml\Editor\Form\Element\Column */
     $columnRight = $form->addField('column-right-' . $tab, 'column', []);
     $columnRight->setRendererFactory($this->_rendererFactory)->setElementsFactory($this->_elementsFactory);
     $columns = ['left' => $columnLeft, 'middle' => $columnMiddle, 'right' => $columnRight];
     return $columns;
 }
开发者ID:opexsw,项目名称:magento2,代码行数:21,代码来源:Builder.php

示例4: _addField

 /**
  * Add a field to the form or fieldset
  * Form and fieldset have same abstract
  *
  * @param \Magento\Framework\Data\Form|\Magento\Framework\Data\Form\Element\Fieldset $formOrFieldset
  * @param string $elementName
  * @param array $options
  * @param string $type
  * @return \Magento\Framework\Data\Form\Element\AbstractElement
  */
 protected function _addField($formOrFieldset, $elementName, $options = array(), $type = 'text')
 {
     $options = array_merge($options, array('name' => $elementName, 'label' => $this->_recurringPaymentFields->getFieldLabel($elementName), 'note' => $this->_recurringPaymentFields->getFieldComment($elementName), 'disabled' => $this->_isReadOnly));
     if (in_array($elementName, array('period_unit', 'period_frequency'))) {
         $options['required'] = true;
     }
     return $formOrFieldset->addField($elementName, $type, $options);
 }
开发者ID:aiesh,项目名称:magento2,代码行数:18,代码来源:Form.php


注:本文中的Magento\Framework\Data\Form::addField方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。