Development

#1776 ([PATCH] checkbox arrays not checked with fillin enabled)

You must first sign up to be able to contribute.

Ticket #1776 (closed defect: fixed)

Opened 3 years ago

Last modified 2 years ago

[PATCH] checkbox arrays not checked with fillin enabled

Reported by: Eric.Lemoine Assigned to: FabianLange
Priority: minor Milestone: 1.0.14
Component: validation Version: 1.0.4
Keywords: checkbox fillin Cc: jdibiase@proyectoalba.com.ar
Qualification: Ready for core team

Description

When the checkbox controls are arrays, fillin does not work. The bug is in util/sfFillInForm.class.php :

if ($type == 'checkbox' || $type == 'radio')
{
  // checkbox and radio
  $element->removeAttribute('checked');
  if ($this->hasValue($values, $name) && ($this->getValue($values, $name) == $value || !$element->hasAttribute('value')))
  {
    $element->setAttribute('checked', 'checked');
  }
}

The code "$this->getValue($values, $name) == $value" does not work because the getValue method returns an array in that case. So the validation code must be different either we have single checkbox or multiple checkbox.

In fact it is the same bug as this one http://trac.symfony-project.com/trac/ticket/1342 but with checkbox instead of radio

Attachments

checkbox_radio_array.patch (0.9 kB) - added by Jose.Luis.Di.Biase on 08/07/07 02:32:11.
Patch to resolve fill in arrays with radiobuttons and checkboxes
fix1776.patch (1.3 kB) - added by Jose.Luis.Di.Biase on 08/07/07 04:22:08.
svk patch for current symfony version
fix1776-upgrade.patch (5.7 kB) - added by Jose.Luis.Di.Biase on 09/25/07 16:11:54.
new Patch file (includes new tests and correction on symfony coding standars)

Change History

06/22/07 20:47:02 changed by Andrejs.Verza

  • version changed from 1.0.2 to 1.0.4.

I think, Fabien were right when discussed this problem with radiobuttons (ticket 1342), however I confirm that this problem still exists with checkbox arrays.

It is convenient to write like this:

  echo checkbox_tag ('group[]', 1);
  echo checkbox_tag ('group[]', 2);
  echo checkbox_tag ('group[]', 3);
  echo checkbox_tag ('group[]', 'id');

...in that way you receive an array named group. But this case won't work with fillin feature. To make use of the fillin, one needs to rewrite the example like that:

  echo checkbox_tag ('group[1]', 1);
  echo checkbox_tag ('group[2]', 2);
  echo checkbox_tag ('group[3]', 3);
  echo checkbox_tag ('group[id]', 'id');

...which is not that convenient.

07/25/07 15:28:27 changed by davedash

+1

08/06/07 20:22:20 changed by Jose.Luis.Di.Biase

+2

08/07/07 02:32:11 changed by Jose.Luis.Di.Biase

  • attachment checkbox_radio_array.patch added.

Patch to resolve fill in arrays with radiobuttons and checkboxes

08/07/07 02:34:02 changed by Jose.Luis.Di.Biase

Here I have sent the patch to resolv this ticket. Please test it. In a while I will upload the svk patch.

08/07/07 04:22:08 changed by Jose.Luis.Di.Biase

  • attachment fix1776.patch added.

svk patch for current symfony version

08/07/07 13:36:24 changed by Jose.Luis.Di.Biase

  • cc set to jdibiase@proyectoalba.com.ar.

08/14/07 16:46:52 changed by Jose.Luis.Di.Biase

  • summary changed from checkbox arrays not checked with fillin enabled to [PATCH] checkbox arrays not checked with fillin enabled.

09/18/07 15:23:39 changed by Jose.Luis.Di.Biase

  • owner changed from fabien to Jose.Luis.Di.Biase.
  • status changed from new to assigned.
  • qualification set to Unreviewed.

09/18/07 15:24:58 changed by Jose.Luis.Di.Biase

  • qualification changed from Unreviewed to Ready for core team.

09/21/07 16:11:58 changed by Raise

Thanks for the patch Jose, it worked perfectly for me. Hope it gets added to the next release of symfony... sorry you had to take it on yourself, fabien and co must be busy :)

09/21/07 21:58:22 changed by fabien

  • qualification changed from Ready for core team to Patch rejected, quality issue.

To be "ready for core team", the patch must follow symfony coding standard and have some unit/functional tests.

09/25/07 16:11:54 changed by Jose.Luis.Di.Biase

  • attachment fix1776-upgrade.patch added.

new Patch file (includes new tests and correction on symfony coding standars)

09/25/07 16:18:44 changed by Jose.Luis.Di.Biase

Now I think it is complete (I have included some tests in sfFillInFormTest.php). I dont want to abuse of your time but please If something is wrong or missing something in this new patch please tell me. If I can I would help to symfony development.

09/25/07 16:19:03 changed by Jose.Luis.Di.Biase

  • qualification changed from Patch rejected, quality issue to Ready for core team.

04/30/08 18:00:10 changed by FabianLange

  • owner changed from Jose.Luis.Di.Biase to FabianLange.
  • status changed from assigned to new.

04/30/08 18:17:14 changed by FabianLange

  • milestone set to 1.0.14.

04/30/08 18:23:28 changed by FabianLange

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

fixed: (In [8695]) sf1.0: made sfFillInForm work with checkbox arrays as well like checkbox_many[]. including unit tests. fixes #1776, #3399

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.