本文整理汇总了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);
}
示例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;
}
示例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;
}
示例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);
}