dmatthew / magento2-widget-parameters

Useful widget types for Magento 2 like image selector and wysiwyg text editor.
MIT License
56 stars 24 forks source link

doesn't extend \Magento\Framework\Data\Form\Element\AbstractElement #10

Closed andyboltondev closed 4 years ago

andyboltondev commented 4 years ago

Hi,

I have installed this module however when ever I try to load a page that contains one of the widgets (backgroun, textarea, wysiwyg) I get the following error:

\Sixty\Core\Block\Adminhtml\Widget\Type\Textarea doesn't extend \Magento\Framework\Data\Form\Element\AbstractElement

I have added it to an admin form by adding type

$fieldset->addType('test', '\Sixty\Core\Block\Adminhtml\Widget\Type\Textarea');

and then adding the field

$fieldset->addField('test_field', 'test', [ 'name' => 'test_field', 'label' => __('Test'), 'id' => 'test_field', 'title' => __('Test'), 'class' => 'required-entry', 'required' => true, ]);

Please note, I have merged this into our core module, to reduce dependencies, however, testing this without the modification also results with the same error.

Site is on Magento 2.3.1.

Regards, Andy

dmatthew commented 4 years ago

Hmm, I'm not sure you're using this module correctly. What admin form are you using it with?

This module only adds new widget parameters. So for example, take the widget type "CMS Page Link". One of its fields is called "Anchor Custom Text" which has a parameter type of "text" which displays an input box in the admin. In Magento by default there are parameter types of "Text", "Select", and "Block" (and possibly one or two others that I missed). But, if you wanted to add an image, textarea, or wysiwyg field to a widget, you could use this module.

If you're still stuck help me out by adding more details of what you are trying to do.

andyboltondev commented 4 years ago

Hi,

I believe that is what I want to do, unless I'm missing something , had too many late nights.

I have a custom module which adds an admin form where I want to be able to schedule banners and upload images (foreground and background). I have a proof of concept working for this.

I was hoping to use your module to either upload a new image or chooses an existing image for both the background and foreground images.

The following is being used to set the field type of the inputs. $fieldset->addType('test', '\Sixty\Core\Block\Adminhtml\Widget\Type\Textarea');

Then I was hooping to add the field with the following. $fieldset->addField('test_field', 'test', [ 'name' => 'test_field', 'label' => __('Test'), 'id' => 'test_field', 'title' => __('Test'), 'class' => 'required-entry', 'required' => true, ]);

This was the method I had used with a basic image uploader, but possibly I am missing something here or it is outside the scope of your module.