Browse Source

status field no null value

feature/ticket
Charly 3 years ago
parent
commit
9ca327ac1c
1 changed files with 22 additions and 21 deletions
  1. +22
    -21
      Field/StatusField.php

+ 22
- 21
Field/StatusField.php View File

*/ */
final class StatusField implements FieldInterface final class StatusField implements FieldInterface
{ {
use FieldTrait;

public static function new(string $propertyName, ?string $label = null, bool $templateToggle = true): self
{
$field = (new self())
->setProperty($propertyName)
->setLabel($label)
->setFormType(ChoiceType::class)
->setFormTypeOption('expanded', true)
->setFormTypeOption('multiple', false)
->setFormTypeOption('choices', ['En ligne' => 1, 'Hors ligne' => 0])
->setCustomOption('toggle_label', 'En ligne');

$template = 'toggle.html.twig' ;
if(!$templateToggle) {
$template = 'status.html.twig' ;
}

$field->setTemplatePath('@LcSov/adminlte/crud/field/'.$template) ;

return $field ;
use FieldTrait;

public static function new(string $propertyName, ?string $label = null, bool $templateToggle = true): self
{
$field = (new self())
->setProperty($propertyName)
->setLabel($label)
->setFormType(ChoiceType::class)
->setFormTypeOption('expanded', true)
->setFormTypeOption('multiple', false)
->setFormTypeOption('choices', ['En ligne' => 1, 'Hors ligne' => 0])
->setFormTypeOption('placeholder', false)
->setCustomOption('toggle_label', 'En ligne');

$template = 'toggle.html.twig';
if (!$templateToggle) {
$template = 'status.html.twig';
} }


$field->setTemplatePath('@LcSov/adminlte/crud/field/' . $template);

return $field;
}

} }

Loading…
Cancel
Save