I got this error when I try to create a custom attribute for products:
The configuration parameter "formElement" is a required for "instruction" field.
InstallData.php
<?php
namespace MyVendor\MyModule\Setup;
use Magento\Eav\Setup\EavSetup;
use Magento\Eav\Setup\EavSetupFactory;
use Magento\Framework\Setup\InstallDataInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
class InstallData implements InstallDataInterface
{
private $eavSetupFactory;
public function __construct(EavSetupFactory $eavSetupFactory)
{
$this->eavSetupFactory = $eavSetupFactory;
}
public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
$eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);
$eavSetup->addAttribute(
\Magento\Catalog\Model\Product::ENTITY,
'instruction',
[
'type' => 'text',
'backend' => '',
'frontend' => 'text',
'label' => 'Installation Manual',
'input' => '',
'class' => '',
'source' => '',
'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL,
'visible' => true,
'required' => false,
'user_defined' => false,
'default' => '',
'searchable' => false,
'filterable' => false,
'comparable' => false,
'visible_on_front' => false,
'used_in_product_listing' => true,
'unique' => false,
'apply_to' => 'simple,configurable,virtual,bundle,downloadable,grouped',
'group'=> 'General'
]
);
}
}
I'm using magento 2.1.8.
I read that I have to change the frontend_input in the eav_attribute table in the database, but I don't want to add it manually, and I don't know what do I have to add there.
How can I add this attribute at the setup?
Thanks
1 Answer 1
You can add attributes on admin... Stores> Attributes> Products
Explore related questions
See similar questions with these tags.