AddToModal::renderModalContent()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 11
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 18
rs 9.9
1
<?php
2
/**
3
 * Created for IG Monitoring.
4
 * User: jakim <[email protected]>
5
 * Date: 27.02.2018
6
 */
7
8
namespace app\modules\admin\widgets\favorites;
9
10
11
use app\models\Favorite;
12
use app\modules\admin\widgets\base\ModalWidget;
13
use yii\helpers\Html;
14
use yii\helpers\Url;
15
use yii\widgets\ActiveForm;
16
17
class AddToModal extends ModalWidget
18
{
19
    public $modalHeader = 'Add to favorites';
20
    public $modalToggleButton = [
21
        'label' => '<span class="fa fa-star text-yellow"></span> Add list to favorites',
22
        'class' => 'btn btn-sm btn-default',
23
    ];
24
25
    protected function renderModalContent()
26
    {
27
        $model = new Favorite();
28
        $form = ActiveForm::begin([
29
            'action' => ['favorite/create'],
30
        ]);
31
        echo $form->field($model, 'label')->textInput([
32
            'placeholder' => 'Name',
33
            'required' => true,
34
            'autofocus' => true,
35
        ]);
36
        echo $form->field($model, 'url')->hiddenInput(['value' => Url::current()])->label(false);
37
38
        echo Html::hiddenInput('prefix', '<span class=\'fa fa-search\'></span> ');
39
40
        echo Html::submitButton('Save', ['class' => 'btn btn-primary']);
41
42
        ActiveForm::end();
43
    }
44
}