I'm updating a plugin and I need to build a select.
I'm new in Magento2, and I found this idea: Magento 2: How add dropdown in admin form?
I'm building something similar but I'm not able to display it in Admin Panel.
here the function:
<?php
namespace Fattura24\AppFatturazione\Block\System\Config;
class SelectFattureCreaFattura extends
\Magento\Config\Block\System\Config\Form\Field implements
\Magento\Framework\Option\ArrayInterface
{
public function toOptionArray()
{
$result = [];
foreach (self::getOptionArray() as $index => $value) {
$result[] = ['value' => $index, 'label' => $value];
}
return $result;
}
/**
* Retrieve option array
*
* @return string[]
*/
public static function getOptionArray()
{
return [
[1 => __('Disabilitata')],
[2 => __('Fattura NON Elettronica')],
[3 => __('Fattura Elettronica')]
];
}
/**
* Retrieve option array with empty value
*
* @return string[]
*/
public function getAllOptions()
{
$result = [];
foreach (self::getOptionArray() as $index => $value) {
$result[] = ['value' => $index, 'label' => $value];
}
return $result;
}
/**
* Retrieve option text by option value
*
* @param string $optionId
* @return string
*/
public function getOptionText($optionId)
{
$options = self::getOptionArray();
return isset($options[$optionId]) ? $options[$optionId] : null;
}
}
I know I need a template but I don't know where to place it exactly and how to build it. Thanks to all David