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