1

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

Rohan Hapani
17.6k9 gold badges57 silver badges99 bronze badges
asked Oct 12, 2017 at 14:30

1 Answer 1

0

You can add attributes on admin... Stores> Attributes> Products

answered May 14, 2018 at 19:21

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.