Skip to content

Checkboxlist in combination with a persistent parameter, never clear value. #181

Description

@h4kuna

Version: 2.4.7

Bug Description

If you use UI\Form method="get", add checkboxlist with name list and set property $list in presenter like persistent. You never reset form. You must only remove parameters from url.

Steps To Reproduce

  • download sandbox
  • Presenter app/presenters/FormPresenter.php
<?php

namespace App\Presenters;

use Nette\Application\UI\Form;

class FormPresenter extends BasePresenter
{

	/**
	 * @persistent
	 */
	public $list = [];

	protected function createComponentForm()
	{
		$form = new Form();
		$form->setMethod($form::GET);
		$form->addCheckboxList('list', 'List', ['Foo', 'Bar', 'Doe', 'Joe']);
		$form->addSubmit('filter', 'Filter');
		return $form;
	}
}
  • template app/presenters/templates/Form/default.latte
{block content}
{control form}
  • open url http://localhost:8000/form/
  • click on checkbox Foo, send form
  • uncheck Foo, send form and checkbox is still checked
    In form is added hidden input
<input type="hidden" name="list[0]" value="0">

And checkbox list is genereted like:

<input type="checkbox" name="list[]" checked="" value="0">

If check all checkboxes and submit form moretimes, you can see many hidden inputs in form.

Expected Behavior

Is described above

Possible Solution

For this moment I use Nette\Forms\Form for filter form, where i don't need events, but i need to make manually a bool value.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions