Development

#6738 (No is_empty filter for nullable relations)

You must first sign up to be able to contribute.

Ticket #6738 (closed defect: wontfix)

Opened 7 months ago

Last modified 2 months ago

No is_empty filter for nullable relations

Reported by: semaxx Assigned to: Jonathan.Wage
Priority: minor Milestone:
Component: sfDoctrinePlugin Version: 1.2.7
Keywords: admin-generator, filter Cc:
Qualification: Unreviewed

Description

consider the following schema:

TableA:
  columns:
    id:
      type: integer(8)
      unsigned: 1
      primary: true
      autoincrement: true
    name:
      type: string(255)
      notnull: true
    group_id:
      type: integer(8)
      unsigned: 1
      notnull: false
      default: null
  relations:
    MyGroup:
      local: group_id
      foreign: id
      type: one
      onDelete: CASCADE
MyGroup:
  columns:
    id:
      type: integer(8)
      unsigned: 1
      primary: true
      autoincrement: true
    name:
      type: string(255)
      notnull: true 

As you can see, the group_id-field is nullable and therefore it should be possible to filter the admin-generated list of TableA-Objects by empty group_id.

The corresponding sfWidgetFormDoctrineChoice does not support this filter.

How about creating an new filter-class sfWidgetFormFilterDoctrineChoice analogue to sfWidgetFormFilterInput?

But whre to add the corresponding query?

Change History

07/03/09 09:25:30 changed by semaxx

class sfWidgetFormFilterDoctrineChoice extends sfWidgetFormDoctrineChoice {

  protected function configure($options = array(), $attributes = array()) {
    $this->addOption('with_empty', true);
    $this->addOption('empty_label', 'is empty');
    $this->addOption('template', '%input%<br />%empty_checkbox% %empty_label%');

    parent::configure($options, $attributes);
  }

  public function render($name, $value = null, $attributes = array(), $errors = array())
  {
    $values = array_merge(array('text' => '', 'is_empty' => false), is_array($value) ? $value : array());

    return strtr($this->getOption('template'), array(
      '%input%'          => parent::render($name, $value, $attributes, $errors),
      '%empty_checkbox%' => $this->getOption('with_empty') ? $this->renderTag('input', array('type' => 'checkbox', 'name' => $name.'[is_empty]', 'checked' => $values['is_empty'] ? 'checked' : '')) : '',
      '%empty_label%'    => $this->getOption('with_empty') ? $this->renderContentTag('label', $this->getOption('empty_label'), array('for' => $this->generateId($name.'[is_empty]'))) : '',
    ));
  }
}

07/07/09 00:59:16 changed by Jonathan.Wage

Can you provide your changes as a patch/diff?

07/08/09 19:07:41 changed by Jonathan.Wage

  • status changed from new to assigned.

07/08/09 19:30:47 changed by Jonathan.Wage

  • milestone changed from 1.2.8 to 1.3.0.

09/11/09 22:13:32 changed by Jonathan.Wage

  • milestone deleted.

11/30/09 21:40:00 changed by Jonathan.Wage

  • status changed from assigned to closed.
  • resolution set to wontfix.

The Sensio Labs Network

Since 1998, Sensio Labs has been promoting the Open-Source software movement by providing quality web application development, training, consulting.
Sensio Labs also supports several large Open-Source projects.