feat: VivesPOS landing on Winter CMS 1.2 — theme + plugin + Dockerfile
Some checks are pending
Module sub-split / Sub-split (push) Waiting to run
Some checks are pending
Module sub-split / Sub-split (push) Waiting to run
- 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
This commit is contained in:
152
modules/backend/classes/FormWidgetBase.php
Normal file
152
modules/backend/classes/FormWidgetBase.php
Normal file
@@ -0,0 +1,152 @@
|
||||
<?php namespace Backend\Classes;
|
||||
|
||||
use Winter\Storm\Html\Helper as HtmlHelper;
|
||||
|
||||
/**
|
||||
* Form Widget base class
|
||||
* Widgets used specifically for forms
|
||||
*
|
||||
* @package winter\wn-backend-module
|
||||
* @author Alexey Bobkov, Samuel Georges
|
||||
*/
|
||||
abstract class FormWidgetBase extends WidgetBase
|
||||
{
|
||||
|
||||
//
|
||||
// Configurable properties
|
||||
//
|
||||
|
||||
/**
|
||||
* @var \Winter\Storm\Database\Model Form model object.
|
||||
*/
|
||||
public $model;
|
||||
|
||||
/**
|
||||
* @var array Dataset containing field values, if none supplied model should be used.
|
||||
*/
|
||||
public $data;
|
||||
|
||||
/**
|
||||
* @var string Active session key, used for editing forms and deferred bindings.
|
||||
*/
|
||||
public $sessionKey;
|
||||
|
||||
/**
|
||||
* @var bool Render this form with uneditable preview data.
|
||||
*/
|
||||
public $previewMode = false;
|
||||
|
||||
/**
|
||||
* @var bool Determines if this form field should display comments and labels.
|
||||
*/
|
||||
public $showLabels = true;
|
||||
|
||||
//
|
||||
// Object properties
|
||||
//
|
||||
|
||||
/**
|
||||
* @var FormField Object containing general form field information.
|
||||
*/
|
||||
protected $formField;
|
||||
|
||||
/**
|
||||
* @var Backend\Widgets\Form The parent form that contains this field
|
||||
*/
|
||||
protected $parentForm = null;
|
||||
|
||||
/**
|
||||
* @var string Form field name.
|
||||
*/
|
||||
protected $fieldName;
|
||||
|
||||
/**
|
||||
* @var string Model attribute to get/set value from.
|
||||
*/
|
||||
protected $valueFrom;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param $controller Controller Active controller object.
|
||||
* @param $formField FormField Object containing general form field information.
|
||||
* @param $configuration array Configuration the relates to this widget.
|
||||
*/
|
||||
public function __construct($controller, $formField, $configuration = [])
|
||||
{
|
||||
$this->formField = $formField;
|
||||
$this->fieldName = $formField->fieldName;
|
||||
$this->valueFrom = $formField->valueFrom;
|
||||
|
||||
$this->config = $this->makeConfig($configuration);
|
||||
|
||||
$this->fillFromConfig([
|
||||
'model',
|
||||
'data',
|
||||
'sessionKey',
|
||||
'previewMode',
|
||||
'showLabels',
|
||||
'parentForm',
|
||||
]);
|
||||
|
||||
parent::__construct($controller, $configuration);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the parent form for this formwidget
|
||||
*
|
||||
* @return Backend\Widgets\Form|null
|
||||
*/
|
||||
public function getParentForm()
|
||||
{
|
||||
return $this->parentForm;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the HTML element field name for this widget, used for capturing
|
||||
* user input, passed back to the getSaveValue method when saving.
|
||||
* @return string HTML element name
|
||||
*/
|
||||
public function getFieldName()
|
||||
{
|
||||
return $this->formField->getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a unique ID for this widget. Useful in creating HTML markup.
|
||||
*/
|
||||
public function getId($suffix = null)
|
||||
{
|
||||
$id = parent::getId($suffix);
|
||||
$id .= '-' . $this->fieldName;
|
||||
return HtmlHelper::nameToId($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the postback value for this widget. If the value is omitted from
|
||||
* postback data, it will be NULL, otherwise it will be an empty string.
|
||||
* @param mixed $value The existing value for this widget.
|
||||
* @return string The new value for this widget.
|
||||
*/
|
||||
public function getSaveValue($value)
|
||||
{
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value for this form field,
|
||||
* supports nesting via HTML array.
|
||||
* @return string
|
||||
*/
|
||||
public function getLoadValue()
|
||||
{
|
||||
if ($this->formField->value !== null) {
|
||||
return $this->formField->value;
|
||||
}
|
||||
|
||||
$defaultValue = !$this->model->exists
|
||||
? $this->formField->getDefaultFromData($this->data ?: $this->model)
|
||||
: null;
|
||||
|
||||
return $this->formField->getValueFromData($this->data ?: $this->model, $defaultValue);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user