Development

#1849 (Using components as filters)

You must first sign up to be able to contribute.

Ticket #1849 (new defect)

Opened 1 year ago

Last modified 9 months ago

Using components as filters

Reported by: gregory Assigned to: fabien
Priority: minor Milestone:
Component: generator Version: 1.0.3
Keywords: Cc:
Qualification: Accepted

Description

When a component is used to render a filter, the $filters variable is not passed to this component like symfony does with partials.

Let's consider that generator.yml contains the following :

  list:
    filters: [_filter_2, ~filter_3]

Inside the partial, you have normally access to the $filters variable.

Inside the component, you don't have access to this variable. You have to insert manually that line to your logic in order to access it :

  $this->filters = $this->getUser()->getAttributeHolder()->getAll('sf_admin/report/filters');

The reason of that behavior is inside the sfAdminGenerator::getColumnFilterTag() method

    if ($column->isComponent())
    {
      return "get_component('".$this->getModuleName()."', '".$column->getName()."', array('type' => 'list'))";
    }
    else if ($column->isPartial())
    {
      return "get_partial('".$column->getName()."', array('type' => 'filter', 'filters' => \$filters))";
    }

Is there is a particular reason for that ? Can't we have the following instead :

    if ($column->isComponent())
    {
      return "get_component('".$this->getModuleName()."', '".$column->getName()."', array('type' => 'filter', 'filters' => \$filters))";
    }
    else if ($column->isPartial())
    {
      return "get_partial('".$column->getName()."', array('type' => 'filter', 'filters' => \$filters))";
    }

Change History

01/29/08 22:58:51 changed by Simon.Roby

  • qualification set to Unreviewed.

I have also hit this issue. Seems completely wrong to me. I assume it's a copy-paste error in the code...?

01/30/08 00:14:58 changed by dwhittle

  • qualification changed from Unreviewed to Accepted.