Kaynağa Gözat

boolean field + view association_many field

develop
Charly 3 yıl önce
ebeveyn
işleme
a0a6f64648
3 değiştirilmiş dosya ile 67 ekleme ve 68 silme
  1. +0
    -3
      Field/BooleanField.php
  2. +64
    -65
      Field/CollectionField.php
  3. +3
    -0
      Resources/views/adminlte/crud/field/association_many.html.twig

+ 0
- 3
Field/BooleanField.php Dosyayı Görüntüle

@@ -4,9 +4,6 @@ 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\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\TextType;

/**

+ 64
- 65
Field/CollectionField.php Dosyayı Görüntüle

@@ -11,69 +11,68 @@ use Symfony\Component\Form\Extension\Core\Type\CollectionType;

class CollectionField implements FieldInterface
{
use FieldTrait;

public const OPTION_ALLOW_ADD = 'allowAdd';
public const OPTION_ALLOW_DELETE = 'allowDelete';
public const OPTION_ENTRY_IS_COMPLEX = 'entryIsComplex';
public const OPTION_ENTRY_TYPE = 'entryType';
public const OPTION_SHOW_ENTRY_LABEL = 'showEntryLabel';

public static function new(string $propertyName, ?string $label = null): self
{
return (new self())
->setProperty($propertyName)
->setLabel($label)
->setTemplatePath('@LcSov/adminlte/crud/field/collection.html.twig')
->setFormType(CollectionType::class)
/*->addWebpackEncoreEntries('adminlte-field-collection')*/
->setFormTypeOption('allow_add', true)
->setFormTypeOption('allow_delete', true)
->setFormTypeOption('entry_options', array('label' => false))
->addCssClass('field-collection')
->setFormTypeOption('attr', array('class' => 'field-collection-group'))

//Fixe le bug easyadmin lors de la gestion d'un champ de type array, laisser a false pour une entité
->setFormTypeOption('row_attr', array('data-reindex-key' => true));

}

public function allowAdd(bool $allow = true): self
{
$this->setCustomOption(self::OPTION_ALLOW_ADD, $allow);

return $this;
}

public function allowDelete(bool $allow = true): self
{
$this->setCustomOption(self::OPTION_ALLOW_DELETE, $allow);

return $this;
}

/**
* Set this option to TRUE if the collection items are complex form types
* composed of several form fields (EasyAdmin applies a special rendering to make them look better).
*/
public function setEntryIsComplex(bool $isComplex): self
{
$this->setCustomOption(self::OPTION_ENTRY_IS_COMPLEX, $isComplex);

return $this;
}

public function setEntryType(string $formTypeFqcn): self
{
$this->setCustomOption(self::OPTION_ENTRY_TYPE, $formTypeFqcn);

return $this;
}

public function showEntryLabel(bool $showLabel = true): self
{
$this->setCustomOption(self::OPTION_SHOW_ENTRY_LABEL, $showLabel);

return $this;
}
use FieldTrait;

public const OPTION_ALLOW_ADD = 'allowAdd';
public const OPTION_ALLOW_DELETE = 'allowDelete';
public const OPTION_ENTRY_IS_COMPLEX = 'entryIsComplex';
public const OPTION_ENTRY_TYPE = 'entryType';
public const OPTION_SHOW_ENTRY_LABEL = 'showEntryLabel';

public static function new(string $propertyName, ?string $label = null): self
{
return (new self())
->setProperty($propertyName)
->setLabel($label)
->setTemplatePath('@LcSov/adminlte/crud/field/collection.html.twig')
->setFormType(CollectionType::class)
/*->addWebpackEncoreEntries('adminlte-field-collection')*/
->setFormTypeOption('allow_add', true)
->setFormTypeOption('allow_delete', true)
->setFormTypeOption('entry_options', array('label' => false))
->addCssClass('field-collection')
->setFormTypeOption('attr', array('class' => 'field-collection-group'))

//Fixe le bug easyadmin lors de la gestion d'un champ de type array, laisser a false pour une entité
->setFormTypeOption('row_attr', array('data-reindex-key' => true));
}

public function allowAdd(bool $allow = true): self
{
$this->setCustomOption(self::OPTION_ALLOW_ADD, $allow);

return $this;
}

public function allowDelete(bool $allow = true): self
{
$this->setCustomOption(self::OPTION_ALLOW_DELETE, $allow);

return $this;
}

/**
* Set this option to TRUE if the collection items are complex form types
* composed of several form fields (EasyAdmin applies a special rendering to make them look better).
*/
public function setEntryIsComplex(bool $isComplex): self
{
$this->setCustomOption(self::OPTION_ENTRY_IS_COMPLEX, $isComplex);

return $this;
}

public function setEntryType(string $formTypeFqcn): self
{
$this->setCustomOption(self::OPTION_ENTRY_TYPE, $formTypeFqcn);

return $this;
}

public function showEntryLabel(bool $showLabel = true): self
{
$this->setCustomOption(self::OPTION_SHOW_ENTRY_LABEL, $showLabel);

return $this;
}
}

+ 3
- 0
Resources/views/adminlte/crud/field/association_many.html.twig Dosyayı Görüntüle

@@ -0,0 +1,3 @@
{% for entity in field.value %}
<span class="badge badge-secondary">{{ entity }}</span>
{% endfor %}

Yükleniyor…
İptal
Kaydet