<?php
/**
 * @copyright (c) Kufer Software GmbH, Oderstraße 7, D-84453 Mühldorf
 */

namespace Kufer\Web\KuferTools\Utils\WssField\KursPlanung;

class WssFieldKursplanungKurstyp extends \Kufer\Web\KuferTools\Utils\WssField\WssFieldSelect
{
  public function getValueFromPost(string $requestPrefix = '')
  {
    $value = parent::getValueFromPost($requestPrefix);
    if ($value === '-1') {
      return '';
    }

    return $value;
  }

  protected function isMandatoryValueEmpty($value): bool
  {
    $value = parent::getValueFromPost();

    return trim($value) === '-1';
  }

  public function getMandatoryClass(\Column $datamodulColumn): string
  {
    if ($datamodulColumn->mandatory_field) {
      return 'form_mandatory_empty_string_ok';
    }

    return '';
  }
}