Total Complexity | 4 |
Total Lines | 54 |
Duplicated Lines | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
17 | class NotesSideWidget extends ProfileSideWidget |
||
18 | { |
||
19 | public $header = 'Note'; |
||
20 | public $headerIcon = 'comment'; |
||
21 | public $modalToggleButton = [ |
||
22 | 'label' => 'Update', |
||
23 | 'class' => 'btn btn-xs btn-link', |
||
24 | ]; |
||
25 | |||
26 | /** |
||
27 | * @var \app\modules\admin\models\Account |
||
28 | */ |
||
29 | public $model; |
||
30 | |||
31 | protected $note; |
||
32 | |||
33 | public function init() |
||
34 | { |
||
35 | parent::init(); |
||
36 | /** @var AccountNote $model */ |
||
37 | $model = $this->model |
||
38 | ->getAccountNotes() |
||
39 | ->limit(1) |
||
40 | ->one(); |
||
41 | $this->note = $model ? $model->note : null; |
||
|
|||
42 | } |
||
43 | |||
44 | protected function renderModalContent() |
||
45 | { |
||
46 | $form = ActiveForm::begin([ |
||
47 | 'method' => 'post', |
||
48 | 'action' => ['account/update-note', 'id' => $this->model->id], |
||
49 | ]); |
||
50 | echo $form |
||
51 | ->field(new AccountNote(), 'note') |
||
52 | ->label(false) |
||
53 | ->textarea([ |
||
54 | 'maxlength' => true, |
||
55 | 'rows' => 5, |
||
56 | 'placeholder' => true, |
||
57 | 'autofocus' => true, |
||
58 | 'value' => $this->note, |
||
59 | ]); |
||
60 | |||
61 | echo Html::submitButton('Update', ['class' => 'btn btn-small btn-primary']); |
||
62 | |||
63 | ActiveForm::end(); |
||
64 | } |
||
65 | |||
66 | protected function renderBoxContent() |
||
71 | } |
||
72 | } |