PHP code example of stakovicz / ux-collection

1. Go to this page and download the library: Download stakovicz/ux-collection library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

stakovicz / ux-collection example snippets


// ...
use Symfony\UX\FormCollection\Form\CollectionType;

class BlogFormType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            // ...
            ->add('comments', CollectionType::class, [
                // ...
                'button_add' => [
                     // Default text for the add button
                    'text' => 'Add',    
                    // Default attr class for the add button
                    'attr' => ['class' => 'btn btn-outline-primary'] 
                ],
                'button_delete' => [
                    // Default text for the delete button
                    'text' => 'Remove',    
                    // Default class for the delete button
                    'attr' => ['class' => 'btn btn-outline-secondary']    
                ],
            ])
            // ...
        ;
    }

    // ...
}

        $builder
            // ...
            ->add('comments', UXCollectionType::class, [
                // ...
                'attr' => [
                    // Change the controller name 
                    'data-controller' => 'mycollection' 
                ]
            ]);