Development

#2909 ([PATCH] Custom checkbox fields unhandled if unchecked in admin generator)

You must first sign up to be able to contribute.

Ticket #2909 (closed defect: fixed)

Opened 2 years ago

Last modified 1 year ago

[PATCH] Custom checkbox fields unhandled if unchecked in admin generator

Reported by: dancablam Assigned to: fabien
Priority: major Milestone: 1.2.0
Component: generator Version: 1.0.17
Keywords: Checkbox fields ignored admin generator Cc:
Qualification: Unreviewed

Description

When explicitly specifying a checkbox_tag in the admin generator, if the checkbox is UNCHECKED it is omitted from the UPDATE statement. If the box is checked, that field will update as normal with a value of '1'. However when unchecking it, the admin generator ignores the field, and thus once a box is checked it cannot be unchecked.

admin:                {type: select_tag}

Attachments

generator.custombooleancheckboxes.patch (0.9 kB) - added by Calimero on 07/06/08 15:37:32.
Quick patch adapting data handling for boolean value if type not retrieved from the schema AND if the field type is "checkbox_tag"

Change History

(follow-up: ↓ 2 ) 02/29/08 17:25:34 changed by mikael.randy

I have the same problem on Symfony v1.0.11

I use Symfony on a PostGreSQL Database

(in reply to: ↑ 1 ) 04/30/08 12:30:47 changed by manu

  • version changed from 1.0.10 to 1.0.13.

Same on v1.0.13...

07/06/08 15:12:16 changed by Calimero

Same here in v1.0.16. The problem appears to be in the generator's action theme : The expected data type can only be read from the schema, making it impossible to be handled correctly as boolean, see symfony_data_dir/generator/sfPropelAdmin/default/template/actions/action.class.php (@line 200) :

$type = $column->getCreoleType();

That appears to be NULL for a custom field (not defined as boolean in the schema) causing the corresponding update code in the action to look like this :

    if (isset($yourObject['your_custom_boolean_field']))
    {
      $this->yourObject->setYourCustomBooleanField($yourObject['your_custom_boolean_field']);
    }

This is wrong in our case, because if your checkbox is unchecked then it will not be updated because the parameter key is not set in the request.

In my case I really don't want to define that field in the schema, since it belongs to an external table. I suggest that means a new parameter shoud be added to the generator fields to override the way a data field is handled in the action class directly from generator.yml.

07/06/08 15:37:32 changed by Calimero

  • attachment generator.custombooleancheckboxes.patch added.

Quick patch adapting data handling for boolean value if type not retrieved from the schema AND if the field type is "checkbox_tag"

07/06/08 15:39:34 changed by Calimero

The above patch will work if your symfony data dir is named sfdata. Please change the base symfony data directory if that's not the case for you.

07/06/08 15:42:34 changed by Calimero

  • version changed from 1.0.13 to 1.0.16.
  • summary changed from Checkbox fields ignored in admin generator to [PATCH] Custom checkbox fields unhandled if unchecked in admin generator.

08/06/08 10:56:49 changed by karol

  • version changed from 1.0.16 to 1.0.17.

Same in v1.0.17, patch doesn't help, i've add this line and rename /data dir to /sfdata,

08/13/08 10:56:54 changed by karol

  • priority changed from minor to major.

10/30/08 11:28:01 changed by fabien

  • status changed from new to closed.
  • resolution set to fixed.
  • milestone set to 1.2.0.

Won't be fixed for sf 1.0 and 1.1, as this requires a lot of internal modifications to the way the generator works. This is fixed in symfony 1.2.

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.