kachnitel/entity-components-bundle

Reusable Symfony Live Components for entity management (tags, attachments, comments, inline-edit fields)

Maintainers

Package info

github.com/kachnitel/FrdEntityComponentsBundle

Type:symfony-bundle

pkg:composer/kachnitel/entity-components-bundle

Statistics

Installs: 166

Dependents: 1

Suggesters: 1

Stars: 0

Open Issues: 0

0.0.1 2026-02-08 18:42 UTC

This package is auto-updated.

Last update: 2026-03-24 19:07:50 UTC


README

Tests Coverage Assertions PHPStan PHP Symfony

Reusable Symfony Live Components for entity management: tags, file attachments, comments, relationship dropdowns, and a full set of inline-edit field components that work with any Doctrine entity.

Quick Start

1. Install

composer require kachnitel/entity-components-bundle

2. Use any component

{{# Inline-edit a text fieldany entity property with a setter #}}
<twig:K:Entity:Field:String :entity="user" property="name" />

{{# Tag management #}}
<twig:K:Entity:TagManager :entity="product" tagClass="App\\Entity\\Tag" />

{{# File attachments #}}
<twig:K:Entity:AttachmentManager :entity="product" attachmentClass="App\\Entity\\Attachment" />

{{# Comments #}}
<twig:K:Entity:CommentsManager :entity="article" commentClass="App\\Entity\\Comment" />

{{# Relationship / enum dropdown #}}
<twig:K:Entity:SelectRelationship :entity="order" property="status" />

What's Next?

Inline-edit any field

Level 1: Drop in a field component — click ✎ to edit, save, or cancel:

<twig:K:Entity:Field:String  :entity="user"    property="name" />
<twig:K:Entity:Field:Int     :entity="product" property="stock" />
<twig:K:Entity:Field:Bool    :entity="user"    property="active" />
<twig:K:Entity:Field:Date    :entity="event"   property="startsAt" />
<twig:K:Entity:Field:Enum    :entity="order"   property="status" />

Level 2: Association fields with live search:

<twig:K:Entity:Field:Relationship :entity="product"  property="category" />
<twig:K:Entity:Field:Collection   :entity="post"     property="tags" />

Level 3: Add Symfony Validator constraints to the entity — validation runs automatically before flushing:

#[Assert\NotBlank]
#[Assert\Length(max: 100)]
private ?string $name = null;

Level 4: Control who can edit by overriding EditabilityResolverInterface:

Kachnitel\EntityComponentsBundle\Components\Field\EditabilityResolverInterface:
    alias: App\Field\MyEditabilityResolver

Details: Inline-Edit Guide

Tag management

Level 1: Implement TagInterface and TaggableInterface, drop in the component:

<twig:K:Entity:TagManager :entity="product" tagClass="App\\Entity\\Tag" />

Level 2: Read-only badge display:

<twig:K:Entity:TagManager :entity="product" tagClass="App\\Entity\\Tag" :readOnly="true" />

Level 3: Colored categories — return a hex color from getCategoryColor() on your Tag entity. Text color is flipped automatically for contrast.

Details: Tags Guide

File attachments

Level 1: Register a FileHandlerInterface service, implement AttachableInterface, drop in the component:

<twig:K:Entity:AttachmentManager :entity="product" attachmentClass="App\\Entity\\Attachment" />

Level 2: Read-only display, custom collection property:

:config="{ readOnly: true, property: 'media' }"

Level 3: Per-attachment tagging:

:config="{ tagClass: 'App\\Entity\\Tag' }"

Details: Attachments Guide

Comments

Level 1: Implement CommentInterface and CommentableInterface, drop in the component:

<twig:K:Entity:CommentsManager :entity="article" commentClass="App\\Entity\\Comment" />

Level 2: Read-only display, custom collection property:

:config="{ readOnly: true, property: 'notes' }"

Level 3: Limit text length — add a MAX_TEXT_LENGTH constant to your Comment entity and the textarea maxlength is set automatically.

Details: Comments Guide

Relationship / enum dropdown

Level 1: Works out of the box for any entity relation or backed enum:

<twig:K:Entity:SelectRelationship :entity="order" property="region" />

Level 2: Access control, placeholder, label:

:config="{
    role: 'ROLE_EDITOR',
    placeholder: '— Select Region —',
}"

Level 3: Filter records or use a custom repository method:

:config="{ filter: { active: true } }"
:config="{ repositoryMethod: 'findActive' }"

Details: SelectRelationship Guide

Components at a glance

Component Tag Description
TagManager K:Entity:TagManager Colored tag badges with category grouping
AttachmentManager K:Entity:AttachmentManager File upload and attachment list
CommentsManager K:Entity:CommentsManager Threaded comments with delete confirmation
SelectRelationship K:Entity:SelectRelationship Eager dropdown for small option sets and enums
StringField K:Entity:Field:String Inline text edit
IntField K:Entity:Field:Int Inline integer edit
FloatField K:Entity:Field:Float Inline decimal edit
BoolField K:Entity:Field:Bool Inline checkbox toggle
DateField K:Entity:Field:Date Inline date / datetime / time edit
EnumField K:Entity:Field:Enum Inline dropdown for PHP backed enums
RelationshipField K:Entity:Field:Relationship Live-search inline editor for ManyToOne / OneToOne
CollectionField K:Entity:Field:Collection Live-search inline editor for ManyToMany / OneToMany

Documentation

Guide Description
Inline-Edit Fields All field types, validation, editability control, display override
Tags TagManager setup, categories, colors
Attachments AttachmentManager setup, FileHandlerInterface, template blocks
Comments CommentsManager setup, author attribution, text limits
SelectRelationship Dropdown for relations and enums, access control, filtering

Requirements

  • PHP 8.2+
  • Symfony 6.4, 7.x, or 8.x
  • Doctrine ORM
  • Symfony UX Live Component

License

MIT