basically i want to show configuration fields only if value is set. since other fields require first value in order to call external source.
<field id="database" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="2" translate="label" type="select">
<label>Database</label>
<comment>choose database</comment>
<source_model>Wemessage\ModuleX\Model\Config\Source\Database\Source</source_model>
<frontend_model>Wemessage\ModuleX\Model\Config\Source\Database\Model</frontend_model>
</field>
if i remove frontend_model i do see my field in configuration, if i add it back the configuration page is empty.
this is my frontend model file:
namespace Wemessage\ModuleX\Model\Config\Source\Database\Model;
use Wemessage\ModuleX\Helper\Data;
class Model extends \Magento\Config\Block\System\Config\Form\Field
{
/**
* Render fieldset html
*
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
* @return string
*/
public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
{
$html = '';
//$helper = new Data();
//$token = $helper->getConfigValue('module/api/token');
if($token){
$html .= parent::render($element);
}
return $html;
}
}
any idea what can be wrong here ?