/** * 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); }