I created a custom fieldset for a ui_component form to add custom input structures. The problem is, that the inputs are not included in the POST values.
The input you see is just a simple element in the fieldset.phtml you see in the Block code. It has a custom name "test_input_data". I implemented the fieldset similar to the conditions fieldsets on sales rules. The form namespance is shipping_rule_form.
<fieldset name="conditions" sortOrder="20">
<settings>
<collapsible>true</collapsible>
<label translate="true">Conditions</label>
</settings>
<container name="conditions_apply_to" sortOrder="10">
<htmlContent name="html_content">
<block name="conditions_apply_to" class="Company\Namespace\Block\Adminhtml\ShippingRule\Edit\Tab\Conditions" />
</htmlContent>
</container>
</fieldset>
In the Block i am adding the fieldset like this:
protected function _prepareForm()
{
$model = $this->_coreRegistry->registry('current_shipping_rule');
$form = $this->addTabToForm($model);
$this->setForm($form);
return parent::_prepareForm();
}
protected function addTabToForm($model, $fieldsetId = 'conditions_fieldset', $formName = 'shipping_rule_form')
{
if (!$model) {
$id = $this->getRequest()->getParam('entity_id');
$model = $this->_ruleFactory->create();
$model->load($id);
}
$conditionsFieldSetId = 'shipping_rule_form_conditions';
/** @var \Magento\Framework\Data\Form $form */
$form = $this->_formFactory->create();
$form->setHtmlIdPrefix('rule_');
$renderer = $this->_rendererFieldset->setTemplate(
'Remklov_ShippingRule::promo/fieldset.phtml'
)->setFieldSetId(
$conditionsFieldSetId
);
$fieldset = $form->addFieldset(
$fieldsetId,
[
'legend' => __(
'Apply the rule only to the products matched by the rule, if following conditions are met.'
)
]
)->setRule(
$model
)->setRenderer(
$renderer
);
$fieldset->addField(
'conditions',
'text',
[
'name' => 'conditions',
'label' => __('Conditions'),
'title' => __('Conditions'),
'required' => true,
'data-form-part' => $formName
]
);
$form->setValues($model->getData());
return $form;
}
When i do a print_r() on the getParams() in the Save-Controller, it just returns the data of the corresponding model, but not the custom input value. I also tried to add the conditions exactly like in the sales_rule_form.xml, but still nothing is posted.
I could not find out how the submit logic works here and where i maybe missed or need to add logic.