Skip to content
Permalink
Browse files

Forms: support for ignoring form control for output

  • Loading branch information...
ZZromanZZ committed Mar 27, 2013
1 parent c5c5983 commit d16e30d1f07de4f5aa6665c828042630e45808ba
@@ -108,7 +108,7 @@ public function getValues($asArray = FALSE)
{
$values = $asArray ? array() : new Nette\ArrayHash;
foreach ($this->getComponents() as $name => $control) {
if ($control instanceof IControl && !$control->isDisabled() && !$control instanceof ISubmitterControl) {
if ($control instanceof IControl && !$control->isDisabled() && !$control->isIgnored() && !$control instanceof ISubmitterControl) {
$values[$name] = $control->getValue();
} elseif ($control instanceof Container) {
@@ -33,6 +33,7 @@
* @property-read bool $filled
* @property-write $defaultValue
* @property bool $disabled
* @property bool $ignored
* @property-read Nette\Utils\Html $control
* @property-read Nette\Utils\Html $label
* @property-read Nette\Utils\Html $controlPrototype
@@ -64,6 +65,9 @@ abstract class BaseControl extends Nette\ComponentModel\Component implements ICo
/** @var bool */
private $disabled = FALSE;
/** @var bool */
private $ignored = FALSE;
/** @var string */
private $htmlId;
@@ -369,6 +373,30 @@ public function isDisabled()
/**
* Set control ignored or not.
* @param bool
* @return BaseControl provides a fluent interface
*/
public function setIgnored($value = TRUE)
{
$this->ignored = (bool) $value;
return $this;
}
/**
* Is control ignored for output?
* @return bool
*/
public function isIgnored()
{
return $this->ignored;
}
/********************* rendering ****************d*g**/
@@ -59,6 +59,12 @@ function getErrors();
*/
function isDisabled();
/**
* Is control ignored for output?
* @return bool
*/
function isIgnored();
/**
* Returns translated string.
* @param string
@@ -0,0 +1,27 @@
<?php
/**
* Test: Nette\Forms ignored input.
*
* @author Roman Pavlík
* @package Nette\Forms
*/
use Nette\Forms\Form,
Nette\ArrayHash;
require __DIR__ . '/../bootstrap.php';
$form = new Form();
$form->addText("input");
$form->addText("ignoredInput")
->setIgnored();
$values = $form->getValues();
Assert::true(array_key_exists("input", $values));
Assert::false(array_key_exists("ignoredInput", $values));

0 comments on commit d16e30d

Please sign in to comment.
You can’t perform that action at this time.