How to validate custom radio button in magento 2?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
1
down vote

favorite












In my custom module system.xml i added



<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
<tab id="Customodule" translate="label" sortOrder="10">
<label>Settings</label>
</tab>
<section id="ConnSettings" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Connection Settings</label>
<tab>Customodule</tab>
<resource>Vendor_Customodule::config</resource>
<group id="first" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">

<field id="accessLevel" translate="label" type="radios" sortOrder="6" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Access Level</label>
<source_model>VendorCustomModuleModelSourceAccessLevel</source_model>
</field>


Model file is as



class AccessLevel implements MagentoFrameworkOptionArrayInterface

public function toOptionArray()


return [
[
'value' => 'test',
'label' => __('Testing')
],
[
'value' => 'production',
'label' => __('Production')
],
];





I want to select Test option by default. What should i do pelase reply me?









share























  • Please add your group tag from system.xml in your question, so I will add full code with group id
    – Aasim Goriya
    38 mins ago










  • group tag id is "first"
    – iqbal malik
    37 mins ago










  • can you please add full code ?
    – Aasim Goriya
    36 mins ago










  • Please add your config.xml and system.xml code
    – Rohan Hapani
    33 mins ago










  • question edited
    – iqbal malik
    32 mins ago
















up vote
1
down vote

favorite












In my custom module system.xml i added



<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
<tab id="Customodule" translate="label" sortOrder="10">
<label>Settings</label>
</tab>
<section id="ConnSettings" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Connection Settings</label>
<tab>Customodule</tab>
<resource>Vendor_Customodule::config</resource>
<group id="first" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">

<field id="accessLevel" translate="label" type="radios" sortOrder="6" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Access Level</label>
<source_model>VendorCustomModuleModelSourceAccessLevel</source_model>
</field>


Model file is as



class AccessLevel implements MagentoFrameworkOptionArrayInterface

public function toOptionArray()


return [
[
'value' => 'test',
'label' => __('Testing')
],
[
'value' => 'production',
'label' => __('Production')
],
];





I want to select Test option by default. What should i do pelase reply me?









share























  • Please add your group tag from system.xml in your question, so I will add full code with group id
    – Aasim Goriya
    38 mins ago










  • group tag id is "first"
    – iqbal malik
    37 mins ago










  • can you please add full code ?
    – Aasim Goriya
    36 mins ago










  • Please add your config.xml and system.xml code
    – Rohan Hapani
    33 mins ago










  • question edited
    – iqbal malik
    32 mins ago












up vote
1
down vote

favorite









up vote
1
down vote

favorite











In my custom module system.xml i added



<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
<tab id="Customodule" translate="label" sortOrder="10">
<label>Settings</label>
</tab>
<section id="ConnSettings" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Connection Settings</label>
<tab>Customodule</tab>
<resource>Vendor_Customodule::config</resource>
<group id="first" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">

<field id="accessLevel" translate="label" type="radios" sortOrder="6" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Access Level</label>
<source_model>VendorCustomModuleModelSourceAccessLevel</source_model>
</field>


Model file is as



class AccessLevel implements MagentoFrameworkOptionArrayInterface

public function toOptionArray()


return [
[
'value' => 'test',
'label' => __('Testing')
],
[
'value' => 'production',
'label' => __('Production')
],
];





I want to select Test option by default. What should i do pelase reply me?









share















In my custom module system.xml i added



<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
<tab id="Customodule" translate="label" sortOrder="10">
<label>Settings</label>
</tab>
<section id="ConnSettings" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Connection Settings</label>
<tab>Customodule</tab>
<resource>Vendor_Customodule::config</resource>
<group id="first" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">

<field id="accessLevel" translate="label" type="radios" sortOrder="6" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Access Level</label>
<source_model>VendorCustomModuleModelSourceAccessLevel</source_model>
</field>


Model file is as



class AccessLevel implements MagentoFrameworkOptionArrayInterface

public function toOptionArray()


return [
[
'value' => 'test',
'label' => __('Testing')
],
[
'value' => 'production',
'label' => __('Production')
],
];





I want to select Test option by default. What should i do pelase reply me?







magento2





share














share












share



share








edited 32 mins ago

























asked 54 mins ago









iqbal malik

498




498











  • Please add your group tag from system.xml in your question, so I will add full code with group id
    – Aasim Goriya
    38 mins ago










  • group tag id is "first"
    – iqbal malik
    37 mins ago










  • can you please add full code ?
    – Aasim Goriya
    36 mins ago










  • Please add your config.xml and system.xml code
    – Rohan Hapani
    33 mins ago










  • question edited
    – iqbal malik
    32 mins ago
















  • Please add your group tag from system.xml in your question, so I will add full code with group id
    – Aasim Goriya
    38 mins ago










  • group tag id is "first"
    – iqbal malik
    37 mins ago










  • can you please add full code ?
    – Aasim Goriya
    36 mins ago










  • Please add your config.xml and system.xml code
    – Rohan Hapani
    33 mins ago










  • question edited
    – iqbal malik
    32 mins ago















Please add your group tag from system.xml in your question, so I will add full code with group id
– Aasim Goriya
38 mins ago




Please add your group tag from system.xml in your question, so I will add full code with group id
– Aasim Goriya
38 mins ago












group tag id is "first"
– iqbal malik
37 mins ago




group tag id is "first"
– iqbal malik
37 mins ago












can you please add full code ?
– Aasim Goriya
36 mins ago




can you please add full code ?
– Aasim Goriya
36 mins ago












Please add your config.xml and system.xml code
– Rohan Hapani
33 mins ago




Please add your config.xml and system.xml code
– Rohan Hapani
33 mins ago












question edited
– iqbal malik
32 mins ago




question edited
– iqbal malik
32 mins ago










2 Answers
2






active

oldest

votes

















up vote
3
down vote













Please add following code in your etc/config.xml



<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
<default>
<ConnSettings>
<first>
<accessLevel>test</accessLevel>
</first>
</ConnSettings>
</default>
</config>





share|improve this answer






















  • i tried this but nothing happened
    – iqbal malik
    38 mins ago










  • please add your full system.xml code in your question.
    – Aasim Goriya
    38 mins ago










  • @iqbalmalik is this working for you ?
    – Aasim Goriya
    21 mins ago

















up vote
2
down vote













Add this code in your config.xml :



<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
<default>
<ConnSettings>
<first>
<accessLevel>test</accessLevel>
</first>
</ConnSettings>
</default>
</config>


Remove value from core_config_data table and upgrade and deploy.






share|improve this answer




















  • This work for me thanks
    – iqbal malik
    22 mins ago






  • 1




    Happy to help :) Happy coding !! Please accept answer.
    – Rohan Hapani
    22 mins ago











  • +1 for same ans as mine :)
    – Aasim Goriya
    12 mins ago










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',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f245082%2fhow-to-validate-custom-radio-button-in-magento-2%23new-answer', 'question_page');

);

Post as a guest






























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
3
down vote













Please add following code in your etc/config.xml



<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
<default>
<ConnSettings>
<first>
<accessLevel>test</accessLevel>
</first>
</ConnSettings>
</default>
</config>





share|improve this answer






















  • i tried this but nothing happened
    – iqbal malik
    38 mins ago










  • please add your full system.xml code in your question.
    – Aasim Goriya
    38 mins ago










  • @iqbalmalik is this working for you ?
    – Aasim Goriya
    21 mins ago














up vote
3
down vote













Please add following code in your etc/config.xml



<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
<default>
<ConnSettings>
<first>
<accessLevel>test</accessLevel>
</first>
</ConnSettings>
</default>
</config>





share|improve this answer






















  • i tried this but nothing happened
    – iqbal malik
    38 mins ago










  • please add your full system.xml code in your question.
    – Aasim Goriya
    38 mins ago










  • @iqbalmalik is this working for you ?
    – Aasim Goriya
    21 mins ago












up vote
3
down vote










up vote
3
down vote









Please add following code in your etc/config.xml



<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
<default>
<ConnSettings>
<first>
<accessLevel>test</accessLevel>
</first>
</ConnSettings>
</default>
</config>





share|improve this answer














Please add following code in your etc/config.xml



<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
<default>
<ConnSettings>
<first>
<accessLevel>test</accessLevel>
</first>
</ConnSettings>
</default>
</config>






share|improve this answer














share|improve this answer



share|improve this answer








edited 24 mins ago

























answered 41 mins ago









Aasim Goriya

1,8951529




1,8951529











  • i tried this but nothing happened
    – iqbal malik
    38 mins ago










  • please add your full system.xml code in your question.
    – Aasim Goriya
    38 mins ago










  • @iqbalmalik is this working for you ?
    – Aasim Goriya
    21 mins ago
















  • i tried this but nothing happened
    – iqbal malik
    38 mins ago










  • please add your full system.xml code in your question.
    – Aasim Goriya
    38 mins ago










  • @iqbalmalik is this working for you ?
    – Aasim Goriya
    21 mins ago















i tried this but nothing happened
– iqbal malik
38 mins ago




i tried this but nothing happened
– iqbal malik
38 mins ago












please add your full system.xml code in your question.
– Aasim Goriya
38 mins ago




please add your full system.xml code in your question.
– Aasim Goriya
38 mins ago












@iqbalmalik is this working for you ?
– Aasim Goriya
21 mins ago




@iqbalmalik is this working for you ?
– Aasim Goriya
21 mins ago












up vote
2
down vote













Add this code in your config.xml :



<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
<default>
<ConnSettings>
<first>
<accessLevel>test</accessLevel>
</first>
</ConnSettings>
</default>
</config>


Remove value from core_config_data table and upgrade and deploy.






share|improve this answer




















  • This work for me thanks
    – iqbal malik
    22 mins ago






  • 1




    Happy to help :) Happy coding !! Please accept answer.
    – Rohan Hapani
    22 mins ago











  • +1 for same ans as mine :)
    – Aasim Goriya
    12 mins ago














up vote
2
down vote













Add this code in your config.xml :



<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
<default>
<ConnSettings>
<first>
<accessLevel>test</accessLevel>
</first>
</ConnSettings>
</default>
</config>


Remove value from core_config_data table and upgrade and deploy.






share|improve this answer




















  • This work for me thanks
    – iqbal malik
    22 mins ago






  • 1




    Happy to help :) Happy coding !! Please accept answer.
    – Rohan Hapani
    22 mins ago











  • +1 for same ans as mine :)
    – Aasim Goriya
    12 mins ago












up vote
2
down vote










up vote
2
down vote









Add this code in your config.xml :



<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
<default>
<ConnSettings>
<first>
<accessLevel>test</accessLevel>
</first>
</ConnSettings>
</default>
</config>


Remove value from core_config_data table and upgrade and deploy.






share|improve this answer












Add this code in your config.xml :



<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
<default>
<ConnSettings>
<first>
<accessLevel>test</accessLevel>
</first>
</ConnSettings>
</default>
</config>


Remove value from core_config_data table and upgrade and deploy.







share|improve this answer












share|improve this answer



share|improve this answer










answered 29 mins ago









Rohan Hapani

3,77821458




3,77821458











  • This work for me thanks
    – iqbal malik
    22 mins ago






  • 1




    Happy to help :) Happy coding !! Please accept answer.
    – Rohan Hapani
    22 mins ago











  • +1 for same ans as mine :)
    – Aasim Goriya
    12 mins ago
















  • This work for me thanks
    – iqbal malik
    22 mins ago






  • 1




    Happy to help :) Happy coding !! Please accept answer.
    – Rohan Hapani
    22 mins ago











  • +1 for same ans as mine :)
    – Aasim Goriya
    12 mins ago















This work for me thanks
– iqbal malik
22 mins ago




This work for me thanks
– iqbal malik
22 mins ago




1




1




Happy to help :) Happy coding !! Please accept answer.
– Rohan Hapani
22 mins ago





Happy to help :) Happy coding !! Please accept answer.
– Rohan Hapani
22 mins ago













+1 for same ans as mine :)
– Aasim Goriya
12 mins ago




+1 for same ans as mine :)
– Aasim Goriya
12 mins ago

















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f245082%2fhow-to-validate-custom-radio-button-in-magento-2%23new-answer', 'question_page');

);

Post as a guest













































































Comments

Popular posts from this blog

What does second last employer means? [closed]

Installing NextGIS Connect into QGIS 3?

One-line joke