🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@a2lix/symfony-collection

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@a2lix/symfony-collection

Manage your Symfony Form collection simply with vanilla JS

latest
Source
npmnpm
Version
0.6.1
Version published
Weekly downloads
554
9.92%
Maintainers
1
Weekly downloads
 
Created
Source

A2LiX JS - symfony-collection

Manage your Symfony Form collection simply with vanilla JS

npm version

image

Install

npm install @a2lix/symfony-collection

Basic use

See Symfony Encore example (https://github.com/a2lix/Demo/blob/master/assets/app.js)

import a2lix_lib from '@a2lix/symfony-collection/dist/a2lix_sf_collection.min'

a2lix_lib.sfCollection.init()

Advanced use

Default configuration https://github.com/a2lix/symfony-collection/blob/master/src/a2lix_sf_collection.ts#L3-L45 can be customized globally in javascript during init

a2lix_lib.sfCollection.init({
  entry: {
    add: {
        label: 'Add entry'
    },
}}

Or/And more precisely on each collection by using DOM attributes:

  ...
    ->add('categories', CollectionType::class, [
        ...
        'attr' => [
          'data-entry-add-label' => 'Add Category',
        ],
    ])

Nested collection(s)

As advised by SF in this case, you must override the default 'prototype_name' option (https://symfony.com/doc/current/reference/forms/types/collection.html#prototype-name) of the nested collection with a custom name. Then, set this same custom name in a 'data-prototype-name' DOM attribute.

Example of a 'tags' collection nested in a 'categories' collection:

  ...
    ->add('tags', CollectionType::class, [
        'entry_type' => TextType::class,
        'allow_add' => true,
        'allow_delete' => true,
        'delete_empty' => true,
        'by_reference' => false,
        'prototype_name' => '__name2__',  // Advised by Symfony
        'attr' => [
            'data-prototype-name' => '__name2__'  // Required by a2lix_sf_collection
        ],
        'entry_options' => [
            'label' => false,
        ],

Contribute help

docker run -it --rm --user $(id -u):$(id -g) --name a2lix_nodejs -v "$PWD":/usr/src/app -w /usr/src/app node:alpine npm install
docker run -it --rm --user $(id -u):$(id -g) --name a2lix_nodejs -v "$PWD":/usr/src/app -w /usr/src/app node:alpine npm run build

Demo

See Demo project.

Keywords

symfony

FAQs

Package last updated on 02 Jan 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts