return (new self()) | return (new self()) | ||||
->setProperty($propertyName) | ->setProperty($propertyName) | ||||
->setLabel($label) | ->setLabel($label) | ||||
->setTemplatePath('@LcSov/tabler/crud/field/image.html.twig') | |||||
->setTemplatePath('@LcSov/adminlte/crud/field/image.html.twig') | |||||
->addWebpackEncoreEntries('field-filemanager') | ->addWebpackEncoreEntries('field-filemanager') | ||||
->setFormType(FileManagerType::class) | ->setFormType(FileManagerType::class) | ||||
->addCssClass('field-text') | ->addCssClass('field-text') |
<?php | |||||
namespace Lc\SovBundle\Field; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldInterface; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Field\FieldTrait; | |||||
use Lc\SovBundle\Form\Type\FileManagerType; | |||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; | |||||
use Symfony\Component\Form\Extension\Core\Type\TextType; | |||||
/** | |||||
* @author La clic ! <contact@laclic.fr> | |||||
*/ | |||||
final class StatusField implements FieldInterface | |||||
{ | |||||
use FieldTrait; | |||||
public static function new(string $propertyName, ?string $label = null): self | |||||
{ | |||||
return (new self()) | |||||
->setProperty($propertyName) | |||||
->setLabel($label) | |||||
->setTemplatePath('@LcSov/adminlte/crud/field/status.html.twig') | |||||
->setFormType(ChoiceType::class) | |||||
->setFormTypeOption('expanded', false) | |||||
->setFormTypeOption('multiple', false) | |||||
->setFormTypeOption('choices', ['En ligne' => 1, 'Hors ligne' => 0]); | |||||
} | |||||
} |
<div id="{{ html_id }}" class="ea-lightbox"> | <div id="{{ html_id }}" class="ea-lightbox"> | ||||
<img src="{{ asset(field.value.path) }}"> | <img src="{{ asset(field.value.path) }}"> | ||||
</div> | </div> | ||||
{% else %} | |||||
<div class="badge badge-secondary">Aucun(e)</div> | |||||
{% endif %} | {% endif %} |
{% if field.value %} | |||||
{% if field.value == 1 %} | |||||
<div class="badge badge-success">En ligne</div> | <div class="badge badge-success">En ligne</div> | ||||
{% else %} | {% else %} | ||||
<div class="badge badge-danger">Hors ligne</div> | <div class="badge badge-danger">Hors ligne</div> |