Deleting files within the Symfony Input Widget — Indivision Interactive Agency
post-template-default,single,single-post,postid-288,single-format-standard,bridge-core-3.0.2,qode-page-transition-enabled,ajax_fade,page_not_loaded,,qode-overridden-elementors-fonts,qode-child-theme-ver-1.0.0,qode-theme-ver-28.8,qode-theme-bridge,qode_header_in_grid,wpb-js-composer js-comp-ver-6.9.0,vc_responsive,elementor-default,elementor-kit-856

Deleting files within the Symfony Input Widget


Here is a solution for a problem we ran into while working with Symfony.

Problem Description

When using the widget sfWidgetFormInputFileEditable in a form that is embedded using the embedRelation method, file deletion will not work.

For example, suppose that you have two tables named Item and ItemPhoto and they are connected to the relation name ‘Photos’ like so:

class ItemForm extends BaseItemForm {
      public function configure() {

In that case, trying to delete a file with the delete checkbox would not work.


Instead of using a relation name, embed the relation as an alias like this (SomeAlias being any word):

$this->embedRelation('Photos as SomeAlias');

Let us know if you have any questions!

No Comments

Post A Comment