How to use checkbox from product/edit page on Magento configurationn page?Add Checkbox In Magento 2 Admin FormMagento 2 layered navigation with checkbox with multi selectMagento 2 how to use depends in menu for system configuration dependencyMagento2 : Remove fields from Ui Component grid conditionallyHow can I render a tooltip / hint button in Magento 2 Module Configuration?Grid Serializer Magento 2.2 In product edit page - adminhtmlMagento2: Image Upload with Preview and Delete checkbox in Edit Admin FormHow to use Mailchimp template in Magento 2 emailsMagento 2.3 : single checkbox not selected in massStatushow Hide checkbox? toOptionArray()How can i add checkbox under email copy of credit memo need to show (Refund to store credit) in credit memo page in magento 2?
"Correct me if I'm wrong"
Why is it recommended to mix yogurt starter with a small amount of milk before adding to the entire batch?
Where's this swanky house and vineyard near a mountain?
What is "industrial ethernet"?
Why tighten down in a criss-cross pattern?
How do I professionally let my manager know I'll quit over an issue?
What are Elsa's reasons for selecting the Holy Grail on behalf of Donovan?
Can a rogue use Sneak Attack in a Darkness spell cast by another player?
Cut the gold chain
Term or phrase for simply moving a problem from one area to another
How does DC work with natural 20?
What does it mean to not be able to take the derivative of a function multiple times?
Can there be an UN resolution to remove a country from the UNSC?
Hit the Bulls Eye with T in the Center
Does Doppler effect happen instantly?
Why don't countries like Japan just print more money?
Methodology: Writing unit tests for another developer
Am I legally required to provide a (GPL licensed) source code even after a project is abandoned?
Why do all the teams that I have worked with always finish a sprint without completion of all the stories?
Hot coffee brewing solutions for deep woods camping
How large would a mega structure have to be to host 1 billion people indefinitely?
When to remove insignificant variables?
Why is it easier to balance a non-moving bike standing up than sitting down?
Android Material and appcompat Manifest merger failed in react-native or ExpoKit
How to use checkbox from product/edit page on Magento configurationn page?
Add Checkbox In Magento 2 Admin FormMagento 2 layered navigation with checkbox with multi selectMagento 2 how to use depends in menu for system configuration dependencyMagento2 : Remove fields from Ui Component grid conditionallyHow can I render a tooltip / hint button in Magento 2 Module Configuration?Grid Serializer Magento 2.2 In product edit page - adminhtmlMagento2: Image Upload with Preview and Delete checkbox in Edit Admin FormHow to use Mailchimp template in Magento 2 emailsMagento 2.3 : single checkbox not selected in massStatushow Hide checkbox? toOptionArray()How can i add checkbox under email copy of credit memo need to show (Refund to store credit) in credit memo page in magento 2?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I want to use such checkbox instead of Yes/No select in magento 2 module configuration:
How can I achieve this? Maybe there is some tutorial?
magento2 uicomponent
add a comment |
I want to use such checkbox instead of Yes/No select in magento 2 module configuration:
How can I achieve this? Maybe there is some tutorial?
magento2 uicomponent
System configuration?
– Sohel Rana
Jun 12 at 16:46
add a comment |
I want to use such checkbox instead of Yes/No select in magento 2 module configuration:
How can I achieve this? Maybe there is some tutorial?
magento2 uicomponent
I want to use such checkbox instead of Yes/No select in magento 2 module configuration:
How can I achieve this? Maybe there is some tutorial?
magento2 uicomponent
magento2 uicomponent
asked Jun 12 at 16:08
AudiophileAudiophile
16510
16510
System configuration?
– Sohel Rana
Jun 12 at 16:46
add a comment |
System configuration?
– Sohel Rana
Jun 12 at 16:46
System configuration?
– Sohel Rana
Jun 12 at 16:46
System configuration?
– Sohel Rana
Jun 12 at 16:46
add a comment |
1 Answer
1
active
oldest
votes
If you mean from Store Configuration
Tutorial from here:
https://webkul.com/blog/create-checkbox-field-system-configuration-magento-2/
Webkul/DemoModule/etc/adminhtml/system.xml
<field id="checkbox" translate="label" sortOrder="350" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Checkbox</label>
<frontend_model>WebkulDemoModuleBlockSystemConfigCheckbox</frontend_model>
</field>
Webkul/DemoModule/Block/System/Config/Checkbox.php
namespace WebkulDemoModuleBlockSystemConfig;
class Checkbox extends MagentoConfigBlockSystemConfigFormField
const CONFIG_PATH = 'demomodule/group_id/checkbox';
protected $_template = 'Webkul_DemoModule::system/config/checkbox.phtml';
protected $_values = null;
/**
* @param MagentoBackendBlockTemplateContext $context
* @param MagentoConfigModelConfigStructure $configStructure
* @param array $data
*/
public function __construct(
MagentoBackendBlockTemplateContext $context,
array $data = []
)
parent::__construct($context, $data);
/**
* Retrieve element HTML markup.
*
* @param MagentoFrameworkDataFormElementAbstractElement $element
*
* @return string
*/
protected function _getElementHtml(MagentoFrameworkDataFormElementAbstractElement $element)
$this->setNamePrefix($element->getName())
->setHtmlId($element->getHtmlId());
return $this->_toHtml();
public function getValues()
$values = [];
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
foreach ($objectManager->create('WebkulDemoModuleModelConfigSourceCheckbox')->toOptionArray() as $value)
$values[$value['value']] = $value['label'];
return $values;
/**
*
* @param $name
* @return boolean
*/
public function getIsChecked($name)
return in_array($name, $this->getCheckedValues());
/**
*
*get the checked value from config
*/
public function getCheckedValues()
if (is_null($this->_values))
$data = $this->getConfigData();
if (isset($data[self::CONFIG_PATH]))
$data = $data[self::CONFIG_PATH];
else
$data = '';
$this->_values = explode(',', $data);
return $this->_values;
Webkul/DemoModule/Model/Config/Source/Checkbox.php
namespace WebkulDemoModuleModelConfigSource;
/**
* Used in creating options for getting product type value
*
*/
class Checkbox
/**
* Options getter
*
* @return array
*/
public function toOptionArray()
return [['value' => 'checkbox', 'label'=>__('Checkbox')]];
Webkul/DemoModule/view/adminhtml/templates/system/config/checkbox.phtml
<input type="hidden" name="<?php echo $this->getNamePrefix() ?>" value="" /><!-- this is send if nothing is checked -->
<ul class="checkboxes">
<?php foreach ($this->getValues() as $name => $label): ?>
<li>
<input type="checkbox" value="<?php echo $name?>" name="<?php echo $this->getNamePrefix() ?>[]" id="<?php echo $this->getHtmlId() . '_' . $name ?>"<?php echo ($this->getIsChecked($name) ? ' checked="checked"' : '') ?>/><label for="<?php echo $this->getHtmlId() . '_' . $name ?>">
<?php echo $label ?>
</label>
</li>
<?php endforeach;?>
</ul>
If you mean within a form
Something like this
https://magento.stackexchange.com/a/152228/70343
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f278146%2fhow-to-use-checkbox-from-product-edit-page-on-magento-configurationn-page%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
If you mean from Store Configuration
Tutorial from here:
https://webkul.com/blog/create-checkbox-field-system-configuration-magento-2/
Webkul/DemoModule/etc/adminhtml/system.xml
<field id="checkbox" translate="label" sortOrder="350" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Checkbox</label>
<frontend_model>WebkulDemoModuleBlockSystemConfigCheckbox</frontend_model>
</field>
Webkul/DemoModule/Block/System/Config/Checkbox.php
namespace WebkulDemoModuleBlockSystemConfig;
class Checkbox extends MagentoConfigBlockSystemConfigFormField
const CONFIG_PATH = 'demomodule/group_id/checkbox';
protected $_template = 'Webkul_DemoModule::system/config/checkbox.phtml';
protected $_values = null;
/**
* @param MagentoBackendBlockTemplateContext $context
* @param MagentoConfigModelConfigStructure $configStructure
* @param array $data
*/
public function __construct(
MagentoBackendBlockTemplateContext $context,
array $data = []
)
parent::__construct($context, $data);
/**
* Retrieve element HTML markup.
*
* @param MagentoFrameworkDataFormElementAbstractElement $element
*
* @return string
*/
protected function _getElementHtml(MagentoFrameworkDataFormElementAbstractElement $element)
$this->setNamePrefix($element->getName())
->setHtmlId($element->getHtmlId());
return $this->_toHtml();
public function getValues()
$values = [];
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
foreach ($objectManager->create('WebkulDemoModuleModelConfigSourceCheckbox')->toOptionArray() as $value)
$values[$value['value']] = $value['label'];
return $values;
/**
*
* @param $name
* @return boolean
*/
public function getIsChecked($name)
return in_array($name, $this->getCheckedValues());
/**
*
*get the checked value from config
*/
public function getCheckedValues()
if (is_null($this->_values))
$data = $this->getConfigData();
if (isset($data[self::CONFIG_PATH]))
$data = $data[self::CONFIG_PATH];
else
$data = '';
$this->_values = explode(',', $data);
return $this->_values;
Webkul/DemoModule/Model/Config/Source/Checkbox.php
namespace WebkulDemoModuleModelConfigSource;
/**
* Used in creating options for getting product type value
*
*/
class Checkbox
/**
* Options getter
*
* @return array
*/
public function toOptionArray()
return [['value' => 'checkbox', 'label'=>__('Checkbox')]];
Webkul/DemoModule/view/adminhtml/templates/system/config/checkbox.phtml
<input type="hidden" name="<?php echo $this->getNamePrefix() ?>" value="" /><!-- this is send if nothing is checked -->
<ul class="checkboxes">
<?php foreach ($this->getValues() as $name => $label): ?>
<li>
<input type="checkbox" value="<?php echo $name?>" name="<?php echo $this->getNamePrefix() ?>[]" id="<?php echo $this->getHtmlId() . '_' . $name ?>"<?php echo ($this->getIsChecked($name) ? ' checked="checked"' : '') ?>/><label for="<?php echo $this->getHtmlId() . '_' . $name ?>">
<?php echo $label ?>
</label>
</li>
<?php endforeach;?>
</ul>
If you mean within a form
Something like this
https://magento.stackexchange.com/a/152228/70343
add a comment |
If you mean from Store Configuration
Tutorial from here:
https://webkul.com/blog/create-checkbox-field-system-configuration-magento-2/
Webkul/DemoModule/etc/adminhtml/system.xml
<field id="checkbox" translate="label" sortOrder="350" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Checkbox</label>
<frontend_model>WebkulDemoModuleBlockSystemConfigCheckbox</frontend_model>
</field>
Webkul/DemoModule/Block/System/Config/Checkbox.php
namespace WebkulDemoModuleBlockSystemConfig;
class Checkbox extends MagentoConfigBlockSystemConfigFormField
const CONFIG_PATH = 'demomodule/group_id/checkbox';
protected $_template = 'Webkul_DemoModule::system/config/checkbox.phtml';
protected $_values = null;
/**
* @param MagentoBackendBlockTemplateContext $context
* @param MagentoConfigModelConfigStructure $configStructure
* @param array $data
*/
public function __construct(
MagentoBackendBlockTemplateContext $context,
array $data = []
)
parent::__construct($context, $data);
/**
* Retrieve element HTML markup.
*
* @param MagentoFrameworkDataFormElementAbstractElement $element
*
* @return string
*/
protected function _getElementHtml(MagentoFrameworkDataFormElementAbstractElement $element)
$this->setNamePrefix($element->getName())
->setHtmlId($element->getHtmlId());
return $this->_toHtml();
public function getValues()
$values = [];
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
foreach ($objectManager->create('WebkulDemoModuleModelConfigSourceCheckbox')->toOptionArray() as $value)
$values[$value['value']] = $value['label'];
return $values;
/**
*
* @param $name
* @return boolean
*/
public function getIsChecked($name)
return in_array($name, $this->getCheckedValues());
/**
*
*get the checked value from config
*/
public function getCheckedValues()
if (is_null($this->_values))
$data = $this->getConfigData();
if (isset($data[self::CONFIG_PATH]))
$data = $data[self::CONFIG_PATH];
else
$data = '';
$this->_values = explode(',', $data);
return $this->_values;
Webkul/DemoModule/Model/Config/Source/Checkbox.php
namespace WebkulDemoModuleModelConfigSource;
/**
* Used in creating options for getting product type value
*
*/
class Checkbox
/**
* Options getter
*
* @return array
*/
public function toOptionArray()
return [['value' => 'checkbox', 'label'=>__('Checkbox')]];
Webkul/DemoModule/view/adminhtml/templates/system/config/checkbox.phtml
<input type="hidden" name="<?php echo $this->getNamePrefix() ?>" value="" /><!-- this is send if nothing is checked -->
<ul class="checkboxes">
<?php foreach ($this->getValues() as $name => $label): ?>
<li>
<input type="checkbox" value="<?php echo $name?>" name="<?php echo $this->getNamePrefix() ?>[]" id="<?php echo $this->getHtmlId() . '_' . $name ?>"<?php echo ($this->getIsChecked($name) ? ' checked="checked"' : '') ?>/><label for="<?php echo $this->getHtmlId() . '_' . $name ?>">
<?php echo $label ?>
</label>
</li>
<?php endforeach;?>
</ul>
If you mean within a form
Something like this
https://magento.stackexchange.com/a/152228/70343
add a comment |
If you mean from Store Configuration
Tutorial from here:
https://webkul.com/blog/create-checkbox-field-system-configuration-magento-2/
Webkul/DemoModule/etc/adminhtml/system.xml
<field id="checkbox" translate="label" sortOrder="350" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Checkbox</label>
<frontend_model>WebkulDemoModuleBlockSystemConfigCheckbox</frontend_model>
</field>
Webkul/DemoModule/Block/System/Config/Checkbox.php
namespace WebkulDemoModuleBlockSystemConfig;
class Checkbox extends MagentoConfigBlockSystemConfigFormField
const CONFIG_PATH = 'demomodule/group_id/checkbox';
protected $_template = 'Webkul_DemoModule::system/config/checkbox.phtml';
protected $_values = null;
/**
* @param MagentoBackendBlockTemplateContext $context
* @param MagentoConfigModelConfigStructure $configStructure
* @param array $data
*/
public function __construct(
MagentoBackendBlockTemplateContext $context,
array $data = []
)
parent::__construct($context, $data);
/**
* Retrieve element HTML markup.
*
* @param MagentoFrameworkDataFormElementAbstractElement $element
*
* @return string
*/
protected function _getElementHtml(MagentoFrameworkDataFormElementAbstractElement $element)
$this->setNamePrefix($element->getName())
->setHtmlId($element->getHtmlId());
return $this->_toHtml();
public function getValues()
$values = [];
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
foreach ($objectManager->create('WebkulDemoModuleModelConfigSourceCheckbox')->toOptionArray() as $value)
$values[$value['value']] = $value['label'];
return $values;
/**
*
* @param $name
* @return boolean
*/
public function getIsChecked($name)
return in_array($name, $this->getCheckedValues());
/**
*
*get the checked value from config
*/
public function getCheckedValues()
if (is_null($this->_values))
$data = $this->getConfigData();
if (isset($data[self::CONFIG_PATH]))
$data = $data[self::CONFIG_PATH];
else
$data = '';
$this->_values = explode(',', $data);
return $this->_values;
Webkul/DemoModule/Model/Config/Source/Checkbox.php
namespace WebkulDemoModuleModelConfigSource;
/**
* Used in creating options for getting product type value
*
*/
class Checkbox
/**
* Options getter
*
* @return array
*/
public function toOptionArray()
return [['value' => 'checkbox', 'label'=>__('Checkbox')]];
Webkul/DemoModule/view/adminhtml/templates/system/config/checkbox.phtml
<input type="hidden" name="<?php echo $this->getNamePrefix() ?>" value="" /><!-- this is send if nothing is checked -->
<ul class="checkboxes">
<?php foreach ($this->getValues() as $name => $label): ?>
<li>
<input type="checkbox" value="<?php echo $name?>" name="<?php echo $this->getNamePrefix() ?>[]" id="<?php echo $this->getHtmlId() . '_' . $name ?>"<?php echo ($this->getIsChecked($name) ? ' checked="checked"' : '') ?>/><label for="<?php echo $this->getHtmlId() . '_' . $name ?>">
<?php echo $label ?>
</label>
</li>
<?php endforeach;?>
</ul>
If you mean within a form
Something like this
https://magento.stackexchange.com/a/152228/70343
If you mean from Store Configuration
Tutorial from here:
https://webkul.com/blog/create-checkbox-field-system-configuration-magento-2/
Webkul/DemoModule/etc/adminhtml/system.xml
<field id="checkbox" translate="label" sortOrder="350" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Checkbox</label>
<frontend_model>WebkulDemoModuleBlockSystemConfigCheckbox</frontend_model>
</field>
Webkul/DemoModule/Block/System/Config/Checkbox.php
namespace WebkulDemoModuleBlockSystemConfig;
class Checkbox extends MagentoConfigBlockSystemConfigFormField
const CONFIG_PATH = 'demomodule/group_id/checkbox';
protected $_template = 'Webkul_DemoModule::system/config/checkbox.phtml';
protected $_values = null;
/**
* @param MagentoBackendBlockTemplateContext $context
* @param MagentoConfigModelConfigStructure $configStructure
* @param array $data
*/
public function __construct(
MagentoBackendBlockTemplateContext $context,
array $data = []
)
parent::__construct($context, $data);
/**
* Retrieve element HTML markup.
*
* @param MagentoFrameworkDataFormElementAbstractElement $element
*
* @return string
*/
protected function _getElementHtml(MagentoFrameworkDataFormElementAbstractElement $element)
$this->setNamePrefix($element->getName())
->setHtmlId($element->getHtmlId());
return $this->_toHtml();
public function getValues()
$values = [];
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
foreach ($objectManager->create('WebkulDemoModuleModelConfigSourceCheckbox')->toOptionArray() as $value)
$values[$value['value']] = $value['label'];
return $values;
/**
*
* @param $name
* @return boolean
*/
public function getIsChecked($name)
return in_array($name, $this->getCheckedValues());
/**
*
*get the checked value from config
*/
public function getCheckedValues()
if (is_null($this->_values))
$data = $this->getConfigData();
if (isset($data[self::CONFIG_PATH]))
$data = $data[self::CONFIG_PATH];
else
$data = '';
$this->_values = explode(',', $data);
return $this->_values;
Webkul/DemoModule/Model/Config/Source/Checkbox.php
namespace WebkulDemoModuleModelConfigSource;
/**
* Used in creating options for getting product type value
*
*/
class Checkbox
/**
* Options getter
*
* @return array
*/
public function toOptionArray()
return [['value' => 'checkbox', 'label'=>__('Checkbox')]];
Webkul/DemoModule/view/adminhtml/templates/system/config/checkbox.phtml
<input type="hidden" name="<?php echo $this->getNamePrefix() ?>" value="" /><!-- this is send if nothing is checked -->
<ul class="checkboxes">
<?php foreach ($this->getValues() as $name => $label): ?>
<li>
<input type="checkbox" value="<?php echo $name?>" name="<?php echo $this->getNamePrefix() ?>[]" id="<?php echo $this->getHtmlId() . '_' . $name ?>"<?php echo ($this->getIsChecked($name) ? ' checked="checked"' : '') ?>/><label for="<?php echo $this->getHtmlId() . '_' . $name ?>">
<?php echo $label ?>
</label>
</li>
<?php endforeach;?>
</ul>
If you mean within a form
Something like this
https://magento.stackexchange.com/a/152228/70343
answered Jun 12 at 16:58
Dominic XigenDominic Xigen
1,7601311
1,7601311
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f278146%2fhow-to-use-checkbox-from-product-edit-page-on-magento-configurationn-page%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
System configuration?
– Sohel Rana
Jun 12 at 16:46