瀏覽代碼

Adminlte : ajout fields

tags/0.1
Guillaume 3 年之前
父節點
當前提交
754a880f57
共有 4 個檔案被更改,包括 34 行新增2 行删除
  1. +1
    -1
      Field/FileManagerField.php
  2. +30
    -0
      Field/StatusField.php
  3. +2
    -0
      Resources/views/adminlte/crud/field/image.html.twig
  4. +1
    -1
      Resources/views/adminlte/crud/field/status.html.twig

+ 1
- 1
Field/FileManagerField.php 查看文件

@@ -22,7 +22,7 @@ final class FileManagerField implements FieldInterface
return (new self())
->setProperty($propertyName)
->setLabel($label)
->setTemplatePath('@LcSov/tabler/crud/field/image.html.twig')
->setTemplatePath('@LcSov/adminlte/crud/field/image.html.twig')
->addWebpackEncoreEntries('field-filemanager')
->setFormType(FileManagerType::class)
->addCssClass('field-text')

+ 30
- 0
Field/StatusField.php 查看文件

@@ -0,0 +1,30 @@
<?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]);
}

}

+ 2
- 0
Resources/views/adminlte/crud/field/image.html.twig 查看文件

@@ -10,4 +10,6 @@
<div id="{{ html_id }}" class="ea-lightbox">
<img src="{{ asset(field.value.path) }}">
</div>
{% else %}
<div class="badge badge-secondary">Aucun(e)</div>
{% endif %}

+ 1
- 1
Resources/views/adminlte/crud/field/status.html.twig 查看文件

@@ -1,5 +1,5 @@

{% if field.value %}
{% if field.value == 1 %}
<div class="badge badge-success">En ligne</div>
{% else %}
<div class="badge badge-danger">Hors ligne</div>

Loading…
取消
儲存