<?php

/**
 * Shared status fieldset used in form tabs/details.
 *
 * @var string $statusFieldName
 * @var string $statusFieldId
 * @var string $statusFieldValue
 * @var array<string, string> $statusFieldOptions
 * @var string $statusFieldHint
 * @var string $statusFieldDisabledAttr
 * @var string $disabledAttr
 */

$statusFieldName = (string) ($statusFieldName ?? 'active');
$statusFieldId = (string) ($statusFieldId ?? $statusFieldName);
$statusFieldValue = (string) ($statusFieldValue ?? '1');
$statusFieldOptions = $statusFieldOptions ?? [
  '1' => t('Active'),
  '0' => t('Inactive'),
];
$statusFieldHint = (string) ($statusFieldHint ?? t('Inactive entries are hidden in lists and selections.'));
$statusFieldDisabledAttr = (string) ($statusFieldDisabledAttr ?? ($disabledAttr ?? ''));

?>
<fieldset>
  <legend><small><?php e(t('Visibility')); ?></small></legend>
  <label for="<?php e($statusFieldId); ?>">
    <span><?php e(t('Status')); ?></span>
    <select name="<?php e($statusFieldName); ?>" id="<?php e($statusFieldId); ?>" <?php e($statusFieldDisabledAttr); ?>>
      <?php foreach ($statusFieldOptions as $statusOptionValue => $statusOptionLabel): ?>
        <option value="<?php e((string) $statusOptionValue); ?>" <?php if ($statusFieldValue === (string) $statusOptionValue) { ?>selected<?php } ?>>
          <?php e($statusOptionLabel); ?>
        </option>
      <?php endforeach; ?>
    </select>
  </label>
  <small class="muted"><?php e($statusFieldHint); ?></small>
</fieldset>
