<?php
/**
 * @copyright (c) Kufer Software GmbH, Loisachstrasse 4, D-84453 Mühldorf
 */

namespace Kufer\KuferTools\Utils\WssField;

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

    return $value;
  }

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

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

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

    return '';
  }
}