Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiline admin field is broken #8086

Closed
wintermute-84 opened this issue Jan 10, 2017 · 10 comments
Closed

Multiline admin field is broken #8086

wintermute-84 opened this issue Jan 10, 2017 · 10 comments
Labels
bug report Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release

Comments

@wintermute-84
Copy link

Preconditions

  1. Magento version 2.1.3
  2. PHP 7

Steps to reproduce

  1. Add field type="multiline" in any form in admin.
  2. Save values in multiple fields

Expected result

  1. Values are displayed as saved
  2. Ability to add new lines

Actual result

screen shot 2017-01-10 at 12 42 15

1. The plus button (or any other way to add additional lines) is missing Saved values are not exploded correctly when populating the fields.
@WaPoNe
Copy link
Contributor

WaPoNe commented Jun 6, 2017

Any news on this issue?
I verified it on 2.1.7

@wintermute-84
Copy link
Author

No, the functionality doesn't work.

BUT.

As a work around I've used other method:
See code bellow for a general idea.
screen shot 2017-06-07 at 11 12 45

system.xml

<field id="field_mapping" translate="label" sortOrder="410" showInDefault="1" showInWebsite="1" showInStore="1">
                    <label>Field Mapping</label>
                    <frontend_model>...\...\Block\Adminhtml\Form\Field\Mapping</frontend_model>
                    <backend_model>...\...\Model\Config\Source\Backend\Mapping</backend_model>
                </field>

Backend\Mapping

class Mapping extends \Magento\Framework\App\Config\Value
{
    protected $_customtabs = null;

    /**
     * @param \Magento\Framework\Model\Context $context
     * @param \Magento\Framework\Registry $registry
     * @param \Magento\Framework\App\Config\ScopeConfigInterface $config
     * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList
     * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
     * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
     * @param array $data
     */
    public function __construct(
        \Magento\Framework\Model\Context $context,
        \Magento\Framework\Registry $registry,
        \Magento\Framework\App\Config\ScopeConfigInterface $config,
        \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList,
        \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
        \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
        array $data = []
    ) {
        parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data);
    }
    
    /**
     * Process data after load
     *
     * @return void
     */
    protected function _afterLoad()
    {
        $value = $this->getValue();
        $arr = unserialize($value);

        $this->setValue($arr);
    }

    /**
     * Prepare data before save
     *
     * @return void
     */
    public function beforeSave()
    {
        $value = $this->getValue();
        unset($value['__empty']);
        $arr = serialize($value);
        
        $this->setValue($arr);
    }
}

Field\Mapping

class Mapping extends \Magento\Config\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray
{

    private $yesnoRenderer;

    /**
     * Prepare to render
     *
     * @return void
     */
    protected function _prepareToRender()
    {
        $this->addColumn('attribute_code', ['label' => __('Attribute Code')]);
        $this->addColumn('mapped_code', ['label' => __('Mapped Value')]);
        $this->addColumn('overwrite_status', ['label' => __('Overwrite?'), 'renderer'  => $this->getYesnoRenderer()]);
        $this->_addAfter = false;
        $this->_addButtonLabel = __('Add');
    }

    protected function getYesnoRenderer()
    {
        if (!$this->yesnoRenderer) {
            $this->yesnoRenderer = $this->getLayout()->createBlock(
                Yesno::class,
                '',
                ['data' => ['is_render_to_js_template' => true]]
            );
            $this->yesnoRenderer->setClass('overwrite_status');
        }
        return $this->yesnoRenderer;
    }

    /**
     * Prepare existing row data object
     *
     * @param \Magento\Framework\DataObject $row
     * @return void
     */
    protected function _prepareArrayRow(\Magento\Framework\DataObject $row)
    {
        $optionExtraAttr = [];

        $optionExtraAttr['option_' . $this->getYesnoRenderer()->calcOptionHash($row->getData('overwrite_status'))] =
            'selected="selected"';

        $row->setData('option_extra_attrs',$optionExtraAttr);
    }
}

@IlnitskiyArtem
Copy link

@Dukeofvampires, Thanks for reporting this issue.
We've created internal ticket MAGETWO-69696 to address this issue.

@veloraven veloraven added the Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development label Jun 30, 2017
@magento-engcom-team magento-engcom-team added 2.1.x Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development bug report Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed and removed G1 Passed labels Sep 5, 2017
@magento-engcom-team
Copy link
Contributor

@wintermute-84, thank you for your report.
We've created internal ticket(s) MAGETWO-69696 to track progress on the issue.

@magento-engcom-team magento-engcom-team added 2.2.x Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release labels Oct 12, 2017
@magento-engcom-team
Copy link
Contributor

Hi @wintermute-84

This ticket has been marked as "Triage Wanted" due to low user involvement over time. Over the next 2 weeks we are looking for additional community feedback to decide if it should be archived or not. More information on this is available on the GitHub wiki.

Thank you for collaboration.

@wintermute-84
Copy link
Author

what about internal ticket MAGETWO-69696?

@magento-engcom-team
Copy link
Contributor

@wintermute-84 Unfortunately internal ticket is still open.

@magento-engcom-team
Copy link
Contributor

Hi @vivekkumarcedcoss. Thank you for working on this issue.
Looks like this issue is already verified and confirmed. But if your want to validate it one more time, please, go though the following instruction:

  • 1. Add/Edit Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 2. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento-engcom-team give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 3. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento-engcom-team give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

  • 4. If the issue is not relevant or is not reproducible any more, feel free to close it.

@vivekkumarcedcoss vivekkumarcedcoss removed their assignment Jan 19, 2019
@magento-engcom-team magento-engcom-team added the Fixed in 2.3.x The issue has been fixed in 2.3 release line label Feb 24, 2019
@magento-engcom-team
Copy link
Contributor

Hi @wintermute-84. Thank you for your report.
The issue has been fixed in #20371 by @vivekkumarcedcoss in 2.3-develop branch
Related commit(s):

The fix will be available with the upcoming 2.3.2 release.

magento-engcom-team added a commit that referenced this issue Feb 24, 2019
 - Merge Pull Request #20371 from cedcommerce/magento2:2.3-develop-issue-fix-8086
 - Merged commits:
   1. ddb1137
eduard13 pushed a commit to eduard13/magento2 that referenced this issue Feb 24, 2019
vivekkumarcedcoss added a commit to vivekkumarcedcoss/magento2 that referenced this issue Mar 4, 2019
@magento-engcom-team magento-engcom-team added the Fixed in 2.2.x The issue has been fixed in 2.2 release line label Mar 30, 2019
@magento-engcom-team
Copy link
Contributor

Hi @wintermute-84. Thank you for your report.
The issue has been fixed in #21561 by @vivekkumarcedcoss in 2.2-develop branch
Related commit(s):

The fix will be available with the upcoming 2.2.9 release.

magento-engcom-team added a commit that referenced this issue Mar 30, 2019
…broken #21561

 - Merge Pull Request #21561 from vivekkumarcedcoss/magento2:2.2-develop-PR-port-20371
 - Merged commits:
   1. 96c8329
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release
Projects
None yet
Development

No branches or pull requests

7 participants