Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Formattribute.php
Go to the documentation of this file.
1 <?php
11 
13 
14 class Formattribute extends \Magento\Backend\Block\Widget\Form\Generic
15 {
19  protected function _prepareForm()
20  {
22  $form = $this->_formFactory->create();
23 
24  $fieldset = $form->addFieldset('set_fieldset', ['legend' => __('Add New Attribute')]);
25 
26  $fieldset->addField(
27  'new_attribute',
28  'text',
29  ['label' => __('Name'), 'name' => 'new_attribute', 'required' => true]
30  );
31 
32  $fieldset->addField(
33  'submit',
34  'note',
35  [
36  'text' => $this->getLayout()->createBlock(
37  \Magento\Backend\Block\Widget\Button::class
38  )->setData(
39  ['label' => __('Add Attribute'), 'onclick' => 'this.form.submit();', 'class' => 'add']
40  )->toHtml()
41  ]
42  );
43 
44  $form->setUseContainer(true);
45  $form->setMethod('post');
46  $this->setForm($form);
47  }
48 }
setForm(\Magento\Framework\Data\Form $form)
Definition: Form.php:112
__()
Definition: __.php:13
setData($key, $value=null)
Definition: DataObject.php:72