Last active
January 7, 2019 11:01
-
-
Save reyostallenberg/9271618d8a2da97c817ca13b232f2e56 to your computer and use it in GitHub Desktop.
Symfony ColletionType add button (using jQuery)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
/* | |
* This file is part of the VaultUtilities package. | |
* (c) Connect Holland. | |
*/ | |
namespace ConnectHolland\VaultUtilities\Form\Type; | |
use use Symfony\Component\Form\Extension\Core\Type\CollectionType; | |
use Symfony\Component\Form\AbstractType; | |
use Symfony\Component\Form\FormBuilderInterface; | |
use App\Form\Type\EntryType; | |
class FormFieldType extends AbstractType | |
{ | |
/** | |
* {@inheritdoc} | |
*/ | |
public function buildForm(FormBuilderInterface $builder, array $options) | |
{ | |
$builder | |
->add('additional', CollectionType::class, [ | |
'entry_type' => EntryType::class, | |
'entry_options' => [ | |
'label' => false, | |
], | |
'delete_empty' => function ($data) { | |
return is_null($data); | |
}, | |
'allow_delete' => true, | |
'attr' => [ | |
'data-add-button-template' => '<button type="button" class="btn"><i class="fas fa-plus"></i> </button>', | |
'data-remove-button-template' => '<button type="button" class="btn"><i class="fas fa-minus"></i> </button>', | |
], | |
]) | |
; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment