Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'feature/fieldset-remove'
Browse files Browse the repository at this point in the history
  • Loading branch information
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/BaseInputFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,18 @@ public function has($name)
return (array_key_exists($name, $this->inputs));
}

/**
* Remove a named input
*
* @param string $name
* @return InputFilterInterface
*/
public function remove($name)
{
unset($this->inputs[$name]);
return $this;
}

/**
* Set data to use when validating and filtering
*
Expand Down
8 changes: 8 additions & 0 deletions src/InputFilterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ public function get($name);
*/
public function has($name);

/**
* Remove a named input
*
* @param string $name
* @return InputFilterInterface
*/
public function remove($name);

/**
* Set data to use when validating and filtering
*
Expand Down
11 changes: 11 additions & 0 deletions test/BaseInputFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,17 @@ public function testCanAddInputFilterAsInput()
$this->assertSame($child, $parent->get('child'));
}

public function testCanRemoveInputFilter()
{
$parent = new InputFilter();
$child = new InputFilter();
$parent->add($child, 'child');
$this->assertEquals(1, count($parent));
$this->assertSame($child, $parent->get('child'));
$parent->remove('child');
$this->assertEquals(0, count($parent));
}

public function getInputFilter()
{
$filter = new InputFilter();
Expand Down

0 comments on commit 88437dd

Please sign in to comment.