Files
vivespos-landing/modules/backend/formwidgets/RelationManager.php
avives 1f72193a64
Some checks are pending
Module sub-split / Sub-split (push) Waiting to run
feat: VivesPOS landing on Winter CMS 1.2 — theme + plugin + Dockerfile
- Base: wintercms/winter branch 1.2 (full framework)
- Theme vivespos: Canvas 7 + Bootstrap 5 CDN, custom CSS
- Layout: deferred GTM/GA4 tracking, JSON-LD SoftwareApplication
- Partials: hero (offline-first), features, modes (offline/nube toggle),
  screenshots, pricing (3 planes), comparison, FAQ, CTA
- Plugin VivesPOS.Site with ContactForm
- Dockerfile: PHP 8.2 Apache, port 80, healthcheck
- Added winter/wn-pages, blog, sitemap, seo plugins
- Active theme set to vivespos
2026-08-21 19:29:00 -06:00

85 lines
2.1 KiB
PHP

<?php
namespace Backend\FormWidgets;
use Backend\Classes\FormField;
use Backend\Classes\FormWidgetBase;
use Illuminate\Support\Facades\Lang;
use Winter\Storm\Exception\SystemException;
class RelationManager extends FormWidgetBase
{
/**
* @inheritDoc
*/
protected $defaultAlias = 'relationmanager';
/**
* Disables the ability to add, update, delete or create relations.
*/
protected ?bool $readOnly = null;
/**
* Path to controller action to open a record.
*/
protected ?string $recordUrl = null;
/**
* Custom JavaScript code to execute when clicking on a record.
*/
protected ?string $recordOnClick = null;
/**
* Relation name if different from the field name.
*/
protected string $relation = '';
public function init(): void
{
$this->fillFromConfig([
'readOnly',
'recordUrl',
'recordOnClick',
'relation',
]);
if (!isset($this->readOnly) && $this->config->previewMode) {
$this->readOnly = $this->config->previewMode;
}
}
public function render()
{
if (!$this->controller->isClassExtendedWith(\Backend\Behaviors\RelationController::class)) {
$error = Lang::get('backend::lang.relation.missing_behavior', [
'field' => $this->formField->fieldName,
'controller' => get_class($this->controller),
]);
throw new SystemException($error);
}
$options = [];
if (!is_null($this->readOnly)) {
$options['readOnly'] = $this->readOnly;
}
if (!is_null($this->recordUrl)) {
$options['recordUrl'] = $this->recordUrl;
}
if (!is_null($this->recordOnClick)) {
$options['recordOnClick'] = $this->recordOnClick;
}
$relation = $this->relation ?: $this->formField->fieldName;
return $this->controller->relationRender($relation, $options);
}
public function getSaveValue($value)
{
return FormField::NO_SAVE_DATA;
}
}