Passed
Push — master ( 596a36...36fff2 )
by Fabio
05:01
created

TActiveHiddenField::addAttributesToRender()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 7
ccs 0
cts 6
cp 0
crap 2
rs 10
1
<?php
2
/**
3
 * TActiveHiddenField class file.
4
 *
5
 * @author Carl G. Mathisen <[email protected]>
6
 * @link https://github.com/pradosoft/prado
7
 * @license https://github.com/pradosoft/prado/blob/master/LICENSE
8
 * @package Prado\Web\UI\ActiveControls
9
 */
10
11
namespace Prado\Web\UI\ActiveControls;
12
13
use Prado\Prado;
14
use Prado\Web\UI\WebControls\THiddenField;
15
16
/**
17
 * TActiveHiddenField class
18
 *
19
 * TActiveHiddenField displays a hidden input field on a Web page.
20
 * The value of the input field can be accessed via {@link getValue Value} property.
21
 *
22
 * @author Carl G. Mathisen <[email protected]>
23
 * @package Prado\Web\UI\ActiveControls
24
 * @since 3.1
25
 */
26
class TActiveHiddenField extends THiddenField implements IActiveControl
27
{
28
	/**
29
	 * Creates a new callback control, sets the adapter to
30
	 * TActiveControlAdapter. If you override this class, be sure to set the
31
	 * adapter appropriately by, for example, by calling this constructor.
32
	 */
33 1
	public function __construct()
34
	{
35 1
		parent::__construct();
36 1
		$this->setAdapter(new TActiveControlAdapter($this));
37 1
	}
38
39
	/**
40
	 * @return TBaseActiveCallbackControl standard callback control options.
41
	 */
42 1
	public function getActiveControl()
43
	{
44 1
		return $this->getAdapter()->getBaseActiveControl();
0 ignored issues
show
Bug introduced by
The method getBaseActiveControl() does not exist on Prado\Web\UI\TControlAdapter. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

44
		return $this->getAdapter()->/** @scrutinizer ignore-call */ getBaseActiveControl();
Loading history...
45
	}
46
47
	/**
48
	 * @return TCallbackClientSide client side request options.
49
	 */
50
	public function getClientSide()
51
	{
52
		return $this->getAdapter()->getBaseActiveControl()->getClientSide();
53
	}
54
55
	/**
56
	 * Client-side Value property can only be updated after the OnLoad stage.
57
	 * @param string $value text content for the hidden field
58
	 */
59 1
	public function setValue($value)
60
	{
61 1
		if (parent::getValue() === $value) {
62
			return;
63
		}
64
65 1
		parent::setValue($value);
66 1
		if ($this->getActiveControl()->canUpdateClientSide() && $this->getHasLoadedPostData()) {
67
			$this->getPage()->getCallbackClient()->setValue($this, $value);
68
		}
69 1
	}
70
}
71