You can call your css and js by using Vendorname_Modulename in in the head block. So you need to pass Vendorname_Modulename
Try below code in your layout.xml file :
<head>
<css src="Vendorname_Modulename/css/jquery.dataTables.min.css"/>
</head>
Make sure your css and js location are correct .
app\design\frontend\Magento\luma\Vendorname_Modulename\web\css\yourcss.css
app\design\frontend\Magento\luma\Vendorname_Modulename\web\js\yourjs.js
After that run below commands :
php bin/magento cache:clean
php bin/magento setup:static-content:deploy
You can try this :
namespace Vendor\ModuleName\Setup;
use Magento\Customer\Setup\CustomerSetupFactory;
use Magento\Customer\Model\Customer;
use Magento\Eav\Model\Entity\Attribute\Set as AttributeSet;
use Magento\Eav\Model\Entity\Attribute\SetFactory as AttributeSetFactory;
use Magento\Framework\Setup\InstallDataInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
/**
* @codeCoverageIgnore
*/
class InstallData implements InstallDataInterface
{
/**
* @var CustomerSetupFactory
*/
protected $customerSetupFactory;
/**
* @var AttributeSetFactory
*/
private $attributeSetFactory;
/**
* @param CustomerSetupFactory $customerSetupFactory
* @param AttributeSetFactory $attributeSetFactory
*/
public function __construct(
CustomerSetupFactory $customerSetupFactory,
AttributeSetFactory $attributeSetFactory
) {
$this->customerSetupFactory = $customerSetupFactory;
$this->attributeSetFactory = $attributeSetFactory;
}
/**
* {@inheritdoc}
*/
public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
/** @var CustomerSetup $customerSetup */
$customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);
$customerEntity = $customerSetup->getEavConfig()->getEntityType('customer');
$attributeSetId = $customerEntity->getDefaultAttributeSetId();
/** @var $attributeSet AttributeSet */
$attributeSet = $this->attributeSetFactory->create();
$attributeGroupId = $attributeSet->getDefaultGroupId($attributeSetId);
$customerSetup->addAttribute(Customer::ENTITY, 'attribute_code', [
'type' => 'static',
'label' => 'Label Name',
'input' => 'select',
'required' => false,
'visible' => true,
'user_defined' => true,
'sort_order' => 1000,
'position' => 1000,
'system' => 0,
'source' => \Magento\Eav\Model\Entity\Attribute\Source\Table::class,
'option' => ['values' => ['Text1', 'Text2','Text3','Text4','Text5']],
]);
$attribute = $customerSetup->getEavConfig()->getAttribute(Customer::ENTITY, 'attribute_code')
->addData([
'attribute_set_id' => $attributeSetId,
'attribute_group_id' => $attributeGroupId,
'used_in_forms' => [
'customer_account_create',
'adminhtml_checkout',
'adminhtml_customer',
'customer_account_edit'
],
]);
$attribute->save();
}
}
You can edit 'used_in_forms' info according to your need . May be you dont'n need first option in the array .
Best Answer
We have face the same issue(terms and conditions not validating) in our system, and change the below mentioned code. Now working properly.
File Path:
Change the below code:
After changed the code you will following command: