Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Crudit Bundle Laravel Package

2lenet/crudit-bundle

Symfony bundle to rapidly build configurable CRUD back offices with SB Admin layout. Provides list views with pagination, sorting, actions, exports and batch ops, plus datasources, filters, menus, workflows, maps, markdown and Twig helpers.

View on GitHub
Deep Wiki
Context7

Custom CrudIT form types

Autocomplete

The Lle\CruditBundle\Form\Type\AutocompleteType allows you to create a select for entities that is fed by an AJAX autocomplete. It is equivalent to Doctrine's EntityType.

Options :

Name Default Description
class required a FQCN of your entity (e.g. App\Entity\Dummy)
multiple false set this to true if the field is a collection
route null if you want to customize the autocomplete route
url null if you want to customize the autocomplete url

FileType

The Lle\CruditBundle\Form\Type\FileType allows you to create a file input with an interface to show or delete the current file.

Here's a working example:

$builder->add('documentFile', FileType::class, [
    'allow_delete' => true,
    'download_route' => 'app_crudit_entity_download', // Your own route to download the file
    'image_route' => 'app_crudit_entity_downloadthumbnail', // Your own route to get the file (or the thumbnail)
]);

Markdown

The Lle\CruditBundle\Form\Type\MarkdownType allows you to create a Markdown editor textarea.

Cron expression

The Lle\CruditBundle\Form\Type\CronExpressionType allows you to create a cron input with a interface to select value.

CollectionType

Crudit works with CollectionType, but you need to do configure some things on your side.

First, you need to include @LleCrudit/form/custom_types.html.twig in Twig templates:

twig:
    form_themes:
        - 'bootstrap_5_layout.html.twig'
        - '[@LleCrudit](https://github.com/LleCrudit)/form/custom_types.html.twig'

Then you can use the CollectionType. Here's a working example:

// in parent form OrderType.php
$builder->add('lines', CollectionType::class, [
    'label' => 'field.lines',
    'entry_type' => LineType::class,
    'allow_add' => true,
    'allow_delete' => true,
    'by_reference' => false,
    'prototype_name' => '__etape_name__', // not required unless you use multiple CollectionType
]);

// in subform LineType.php
$builder->add('ordre', ItemType::class, [
    'label' => 'field.item',
    'row_attr' => [
        'class' => 'col-1',
    ]
]);

What matters :

  • by_reference is NECESSARY because otherwise Doctrine won't be able to track changes in collection, resulting in deletions that don't happen.
  • prototype_name is necessary when you nest CollectionTypes (a CollectionType inside another CollectionType)
  • use row_attr with Bootstrap columns to size the fields, to get a satisfying result
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
bugban/php-sdk
littlerocket/job-queue-bundle
graham-campbell/flysystem
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
directorytree/opensearch-client
directorytree/opensearch-adapter
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php