Skip to content

How to make checkbox toggle in product edit form

I add attribute to special product like this

$eavSetup->addAttribute(
        Product::ENTITY,
        'dynamic_price',
        [
            'group' => 'Gift Card Information',
            'label' => 'Dynamic Price',
            'type' => 'boolean',
            'input' => 'checkbox',
            'prefer' => 'toggle',
            'frontend' => '',
            'backend' => 'MagentoEavModelEntityAttributeBackendArrayBackend',
            'class' => '',
            'source' => 'MagentoEavModelEntityAttributeSourceBoolean',
            'default' => '0',
            'global' => MagentoEavModelEntityAttributeScopedAttributeInterface::SCOPE_GLOBAL,
            'visible' => true,
            'required' => false,
            'user_defined' => false,
            'searchable' => false,
            'filterable' => false,
            'comparable' => false,
            'visible_on_front' => false,
            'used_in_product_listing' => false,
            'unique' => false,
            'apply_to'=> GiftCard::TYPE_ID,
        ]
    );

But ‘prefer’ => ‘toggle’ not working like using modifier. How to set checkbox toggle?

enter image description here

enter image description here