public function XquantityStockItem::fieldSettingsForm in Commerce Extended Quantity 8
File
- modules/
xquantity_stock/ src/ Plugin/ Field/ FieldType/ XquantityStockItem.php, line 36
Class
- XquantityStockItem
- Defines the 'xquantity_stock' field type.
Namespace
Drupal\xquantity_stock\Plugin\Field\FieldTypeCode
public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
$element = parent::fieldSettingsForm($form, $form_state);
$settings = $this
->getQuantityWidgetSettings();
if (!empty($settings['step'])) {
$element['step']['#step'] = $settings['step'];
$element['min']['#step'] = $settings['step'];
$element['max']['#step'] = $settings['step'];
}
$element['step']['#min'] = $settings['step'];
$min = $settings['min'];
$min = (!is_numeric($min) || $min < 0) && $settings['unsigned'] ? '0' : $min;
$element['min']['#min'] = $min;
$element['max']['#min'] = $min;
$element['threshold'] = [
'#type' => 'number',
'#step' => '1',
'#field_suffix' => $this
->t('seconds', [], [
'context' => 'xquantity stock',
]),
'#title' => $this
->t('Threshold', [], [
'context' => 'xquantity stock',
]),
'#description' => $this
->t('Stock rotation threshold. Read more: <a href=":href" target="_blank">admin/help/xquantity_stock#stock-rotation</a>', [
':href' => '/admin/help/xquantity_stock#stock-rotation',
]),
'#default_value' => $settings['threshold'],
];
return $element;
}