-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Closed
Labels
Fixed in 2.3.xThe issue has been fixed in 2.3 release lineThe issue has been fixed in 2.3 release lineIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentGate 4. Acknowledged. Issue is added to backlog and ready for developmentReproduced on 2.1.xThe issue has been reproduced on latest 2.1 releaseThe issue has been reproduced on latest 2.1 releaseReproduced on 2.2.xThe issue has been reproduced on latest 2.2 releaseThe issue has been reproduced on latest 2.2 releaseReproduced on 2.3.xThe issue has been reproduced on latest 2.3 releaseThe issue has been reproduced on latest 2.3 release
Description
When i try to add new fields to product creationgform in the html name attribute shows up empty, i tried to add the new field both by extending product_form.xml and by using a modifier but both approches ends up the same - a empty name attribute.
I also added these custom fields to
category_form.xml
cms_page_form.xml
Using the exact same method and here it works perfectly.
Preconditions
- Linux - Ubuntu
- Mysql 5.6
- PHP 7.0.12
- Magento 2.1.5
Steps to reproduce
1. Extend product_form.xml to your custom module Vendor/Component/view/adminhtml/ui_component/product_form.xml
2. Add the code you need for the custom field to show up i will show my code of both modifier and by using pure XML
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<fieldset name="hidden_fields"><!-- Hidden fields -->
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="collapsible" xsi:type="boolean">false</item>
<item name="label" xsi:type="string" translate="true">Label</item>
<item name="sortOrder" xsi:type="number">200</item>
<item name="display" xsi:type="string">false</item>
<item name="additionalClasses" xsi:type="string">hiddenFieldSet</item>
</item>
</argument>
<field name="holder">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="dataType" xsi:type="string">string</item>
<item name="formElement" xsi:type="string">input</item>
<item name="additionalClasses" xsi:type="string">holder</item>
</item>
</argument>
</field>
<field name="another_holder">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="dataType" xsi:type="string">string</item>
<item name="formElement" xsi:type="string">input</item>
<item name="additionalClasses" xsi:type="string">another_holder</item>
</item>
</argument>
</field>
</fieldset>
<fieldset name="fields">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="collapsible" xsi:type="boolean">false</item>
<item name="label" xsi:type="string" translate="true">fields</item>
<item name="sortOrder" xsi:type="number">300</item>
<item name="additionalClasses" xsi:type="string">shownFieldSet</item>
</item>
</argument>
<field name="addfield">
<argument name="data" xsi:type="array">
<item name="options" xsi:type="object">VEndor\Namespace\Ui\Component\Listing\Page\Options</item>
<item name="config" xsi:type="array">
<item name="dataType" xsi:type="string">int</item>
<item name="label" xsi:type="string" translate="true">Tilføj nyt felt</item>
<item name="formElement" xsi:type="string">select</item>
<item name="dataScope" xsi:type="string">new_block</item>
<item name="default" xsi:type="string">0</item>
</item>
</argument>
</field>
</fieldset>
</form>
Using modifier
<?php
namespace Vendor\Namespace\Ui\Component\Form;
use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\AbstractModifier;
use Vendor\Namespace\Ui\Component\Listing\Page\Options as SelectOptions;
class AddFillFieldsData extends AbstractModifier
{
public function __construct(
SelectOptions $SelectOptions
)
{
$this->selectOptions = $SelectOptions;
}
public function modifyMeta(array $meta)
{
$meta['fields'] = [
'arguments' => [
'data' => [
'config' => [
'label' => __('Feields'),
'sortOrder' => 300,
'collapsible' => true,
'componentType' => 'fieldset'
]
]
],
'children' => [
'new_field' => [
'arguments' => [
'data' => [
'config' => [
'formElement' => 'select',
'componentType' => 'field',
'options' => $this->selectOptions->toOptionArray(),
'visible' => 1,
'dataScope' => "new_field",
'required' => 0,
'label' => __('Tilføj nyt felt')
]
]
]
]
]
];
return $meta;
}
/**
* {@inheritdoc}
*/
public function modifyData(array $data)
{
return $data;
}
}
di.xml
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<virtualType name="Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Pool">
<arguments>
<argument name="modifiers" xsi:type="array">
<item name="fields" xsi:type="array">
<item name="class" xsi:type="string">Vendor\Namespace\Ui\Component\Form\AddFillFieldsData</item>
<item name="sortOrder" xsi:type="number">1000</item>
</item>
</argument>
</arguments>
</virtualType>
</config>
3. Clear cache and recompile You should now see the field with a blank name attribute
Expected result
Name attribute should not be blank
Actual result
SilvanLaroo
Metadata
Metadata
Assignees
Labels
Fixed in 2.3.xThe issue has been fixed in 2.3 release lineThe issue has been fixed in 2.3 release lineIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentGate 4. Acknowledged. Issue is added to backlog and ready for developmentReproduced on 2.1.xThe issue has been reproduced on latest 2.1 releaseThe issue has been reproduced on latest 2.1 releaseReproduced on 2.2.xThe issue has been reproduced on latest 2.2 releaseThe issue has been reproduced on latest 2.2 releaseReproduced on 2.3.xThe issue has been reproduced on latest 2.3 releaseThe issue has been reproduced on latest 2.3 release