I am creating a module where I am listing a custom table, in admin area. I have a status field in the database. What I want is to disable/remove some of the select option from the status field,when user try to edit, based on the condition.
This is my column which shows status:
<column name="Sub_Status" component="Magento_Ui/js/grid/columns/select">
<settings>
<options class="vendor\module\Model\Status\Source\Status" />
<editor>
<editorType>select</editorType>
</editor>
<dataType>select</dataType>
<label translate="true">Status</label>
</settings>
</column>
I tried to manipulate data on the related class Status.php
<?php
namespace vendor\module\Model\Status\Source;
use Magento\Framework\Data\OptionSourceInterface;
class Status implements OptionSourceInterface
{
protected $status;
//Here you can __construct Model
public function toOptionArray()
{
$result1 = //has all the db records;
$currentDate = date("m-d-Y");
for($i=0;$i<count($result1);$i++){
$subsOrderDate=$result1[$i]['Subcription_Order_Date'];
$subsOrderSKU=$result1[$i]['Sub_Sku'];
$check = 'false';
if($subsOrderDate<$currentDate){
$check = 'true';
}
switch($check){
case 'true':
$result[] = ['value' => 4, 'label' => __('Pending')];
break;
case 'false':
$result[] = ['value' => 3, 'label' => __('On Hold')];
break;
default:
$result[] = [
['value' => 0, 'label' => __('Cancelled')],
['value' => 1, 'label' => __('Original Order')],
['value' => 2, 'label' => __('Payment Failed')],
['value' => 3, 'label' => __('On Hold')],
['value' => 4, 'label' => __('Pending')]
];
}
}
return $result;
}
}
But no luck..How can i achieve this. please help.