Last active
May 7, 2020 02:25
-
-
Save thephucit/cd4dd0ef73de13b03c1696ca0e8d7153 to your computer and use it in GitHub Desktop.
Override các method mặc định của octobercms, thay đổi giao diện form create, update
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$isCreate = $this->formGetContext() == 'create'; | |
$pageUrl = isset($pageUrl) ? $pageUrl : null; | |
?> | |
<div class="form-buttons loading-indicator-container"> | |
<!-- Save --> | |
<a | |
href="javascript:;" | |
class="btn btn-primary oc-icon-check save" | |
data-request="onSave" | |
data-load-indicator="<?= e(trans('backend::lang.form.saving')) ?>" | |
data-request-before-update="$el.trigger('unchange.oc.changeMonitor')" | |
<?php if (!$isCreate): ?>data-request-data="redirect:0"<?php endif ?> | |
data-hotkey="ctrl+s, cmd+s"> | |
<?= e(trans('backend::lang.form.save')) ?> | |
</a> | |
<?php if (!$isCreate): ?> | |
<!-- Save and Close --> | |
<a | |
href="javascript:;" | |
class="btn btn-primary oc-icon-check save" | |
data-request-before-update="$el.trigger('unchange.oc.changeMonitor')" | |
data-request="onSave" | |
data-load-indicator="<?= e(trans('backend::lang.form.saving')) ?>"> | |
<?= e(trans('backend::lang.form.save_and_close')) ?> | |
</a> | |
<?php endif ?> | |
<!-- Preview --> | |
<a | |
href="<?= URL::to($pageUrl) ?>" | |
target="_blank" | |
class="btn btn-primary oc-icon-crosshairs <?php if (!false): ?>hide<?php endif ?>" | |
data-control="preview-button"> | |
<?= e(trans('backend::lang.form.preview_title')) ?> | |
</a> | |
<?php if (!$isCreate): ?> | |
<!-- Delete --> | |
<button | |
type="button" | |
class="btn btn-default empty oc-icon-trash-o" | |
data-request="onDelete" | |
data-request-confirm="Delete this notification rule?" | |
data-control="delete-button"></button> | |
<?php endif ?> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fields: | |
name: | |
label: Name | |
placeholder: New notification rule name | |
attributes: | |
autofocus: 1 | |
toolbar: | |
type: partial | |
path: form_toolbar | |
cssClass: collapse-visible | |
tabs: | |
stretch: true | |
cssClass: master-area | |
paneCssClass: | |
'Actions': 'pane-compact' | |
fields: | |
rule_actions: | |
type: RainLab\Notify\FormWidgets\ActionBuilder | |
tab: Actions | |
rule_conditions: | |
type: RainLab\Notify\FormWidgets\ConditionBuilder | |
tab: Conditions | |
is_enabled: | |
label: Active | |
type: checkbox | |
tab: Settings | |
default: true | |
description: | |
label: Description | |
type: textarea | |
size: tiny | |
tab: Settings | |
code: | |
label: API Code | |
span: auto | |
tab: Settings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function index() | |
{ | |
NotificationRule::syncAll(); | |
$this->asExtension('ListController')->index(); | |
} | |
public function create($eventAlias = null) | |
{ | |
try { | |
if (!$eventAlias) { | |
throw new ApplicationException('Missing a rule code'); | |
} | |
$this->eventAlias = $eventAlias; | |
$this->bodyClass = 'compact-container breadcrumb-fancy'; | |
$this->asExtension('FormController')->create(); | |
} | |
catch (Exception $ex) { | |
$this->handleError($ex); | |
} | |
} | |
public function update($recordId = null, $context = null) | |
{ | |
$this->bodyClass = 'compact-container breadcrumb-fancy'; | |
$this->asExtension('FormController')->update($recordId, $context); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php Block::put('breadcrumb') ?> | |
<ul> | |
<li><a href="<?= Backend::url('rainlab/notify/notifications') ?>"><?= e(trans('rainlab.notify::lang.notifications.menu_label')) ?></a></li> | |
<li><?= e(trans($this->pageTitle)) ?></li> | |
</ul> | |
<?php Block::endPut() ?> | |
<?php if (!$this->fatalError): ?> | |
<div class="layout fancy-layout"> | |
<?= Form::open([ | |
'class' => 'layout', | |
'data-change-monitor' => 'true', | |
'data-window-close-confirm' => e(trans('rainlab.notify::lang.notifications.close_confirm')), | |
'id' => 'post-form' | |
]) ?> | |
<?= $this->formRender() ?> | |
<?= Form::close() ?> | |
</div> | |
<?php else: ?> | |
<div class="padded-container"> | |
<p class="flash-message static error"><?= e(trans($this->fatalError)) ?></p> | |
<p><a href="<?= Backend::url('rainlab/notify/notifications') ?>" class="btn btn-default"><?= e(trans('rainlab.notify::lang.notifications.return')) ?></a></p> | |
</div> | |
<?php endif ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment