-
Notifications
You must be signed in to change notification settings - Fork 0
/
ActiveForm.php
executable file
·57 lines (49 loc) · 1.52 KB
/
ActiveForm.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
namespace makroxyz\materializecss;
/**
* Class ActiveForm
* @package makroxyz\materializecss
*/
class ActiveForm extends \yii\widgets\ActiveForm
{
/**
* @var string the default field class name when calling [[field()]] to create a new field.
* @see fieldConfig
*/
public $fieldClass = 'makroxyz\materializecss\ActiveField';
public $row = true;
/**
* @var string the CSS class that is added to a field container when the associated attribute has validation error.
*/
// public $errorCssClass = 'invalid';
/**
* @var string the CSS class that is added to a field container when the associated attribute is successfully validated.
*/
// public $successCssClass = 'valid';
// public $options = ['class' => 'col s12'];
/**
* Initializes the widget.
* This renders the form open tag.
*/
public function init()
{
if ($this->row) {
$out[] = Html::beginTag('div', ['class' => 'row']);
}
$out[] = parent::init();
echo implode("\n", $out);
}
/**
* Runs the widget.
* This registers the necessary javascript code and renders the form close tag.
* @throws InvalidCallException if `beginField()` and `endField()` calls are not matching
*/
public function run()
{
$out[] = parent::run();
if ($this->row) {
$out[] = Html::endTag('div');
}
echo implode("\n", $out);
}
}