ColorPicker

Color picker Renders a color picker field.

 class Backend\FormWidgets\ColorPicker
extends Backend\Classes\FormWidgetBase

Traits

Trait Description
AssetMaker

Asset Maker Trait Adds asset based methods to a class

ConfigMaker

Config Maker Trait Adds configuration based methods to a class

ErrorMaker

Error Maker Trait Adds exception based methods to a class, goes well with System\Traits\ViewMaker.

EventEmitter

Adds system event related features to any class.

ExtendableTrait

This extension trait is used when access to the underlying base class is not available, such as classes that belong to the foundation framework (Laravel). It is currently used by the Controller and Model classes.

SessionMaker

Session Maker Trait

ViewMaker

View Maker Trait Adds view based methods to a class

WidgetMaker

Widget Maker Trait

Constants

Constant Description
ALL_FORMATS
array ["cmyk","hex","hsl","rgb"]

Properties

public $allowCustom : bool

Allow a custom color

public $allowEmpty : bool

Allow empty value

public $availableColors : array

Default available colors

public $disabled : bool

If true, the color picker is set to disabled mode

public $formats : string | array

Color format(s) to allow for the resulting color value. Specify "all" as a string to allow all formats. Allowed values: 'cmyk', 'hex', 'hsl', 'rgb', 'all'

public $readOnly : bool

If true, the color picker is set to read-only mode

public $showAlpha : bool

Show opacity slider

protected $defaultAlias : mixed

A unique alias to identify this widget.

public $alias : string

Inherited from FormWidgetBase

Defined alias used for this widget.

public $assetPath : string

Inherited from FormWidgetBase

Specifies a path to the asset directory.

public $config : object

Inherited from FormWidgetBase

Supplied configuration.

public $data : array

Inherited from FormWidgetBase

Dataset containing field values, if none supplied model should be used.

public $implement : string | array | null

Inherited from FormWidgetBase

Extensions implemented by this class.

public $layout : string

Inherited from FormWidgetBase

Layout to use for the view.

public $model : Winter\Storm\Database\Model

Inherited from FormWidgetBase

Form model object.

public $previewMode : bool

Inherited from FormWidgetBase

Render this form with uneditable preview data.

public $sessionKey : string

Inherited from FormWidgetBase

Active session key, used for editing forms and deferred bindings.

public $showLabels : bool

Inherited from FormWidgetBase

Determines if this form field should display comments and labels.

public $suppressLayout : bool

Inherited from FormWidgetBase

Prevents the use of a layout.

public $vars : array

Inherited from FormWidgetBase

A list of variables to pass to the page.

protected $assets : array

Inherited from FormWidgetBase

Collection of assets to display in the layout.

protected $configPath : string

Inherited from FormWidgetBase

Specifies a path to the config directory.

protected $controller : Backend\Classes\Controller

Inherited from FormWidgetBase

Backend controller object.

protected static $extendableCallbacks : array

Inherited from FormWidgetBase

Used to extend the constructor of an extendable class. Eg:

Class::extend(function($obj) { })

protected static $extendableClassLoader : ClassLoader | null

Inherited from FormWidgetBase

Class loader instance.

protected static $extendableGuardProperties : bool

Inherited from FormWidgetBase

Indicates if dynamic properties can be created.

protected static $extendableStaticMethods : array

Inherited from FormWidgetBase

Collection of static methods used by behaviors.

protected $extensionData : array

Inherited from FormWidgetBase

Class reflection information, including behaviors.

protected $fatalError : string

Inherited from FormWidgetBase

Object used for storing a fatal error.

protected $fieldName : string

Inherited from FormWidgetBase

Form field name.

protected $formField : FormField

Inherited from FormWidgetBase

Object containing general form field information.

protected $layoutPath : string

Inherited from FormWidgetBase

Specifies a path to the layout directory.

protected $parentForm : Backend\Widgets\Form

Inherited from FormWidgetBase

The parent form that contains this field

protected $valueFrom : string

Inherited from FormWidgetBase

Model attribute to get/set value from.

protected $viewPath : string | array

Inherited from FormWidgetBase

Specifies a path to the views directory.

Methods

public getSaveValue ($value)

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.

Parameters
Property Description
$value
mixed

The existing value for this widget.

Returns
mixed

The new value for this widget.

public init ()

Initialize the widget, called by the constructor and free from its parameters.

Returns
mixed

public prepareVars ()

Prepares the list data

Returns
mixed

public render ()

Renders the widget's primary contents.

Returns
mixed

HTML markup supplied by this widget.

protected getAvailableColors () : array

Gets the appropriate list of colors.

Returns
array

protected getFormats () : array

Returns the allowed color formats.

If no valid formats are specified, the "hex" format will be used.

Returns
array

protected loadAssets ()

Adds widget specific asset files. Use $this->addJs() and $this->addCss() to register new assets to include on the page.

Returns
mixed

public __call ($name, $params)

Inherited from FormWidgetBase
Parameters
Property Description
$name
mixed
$params
mixed
Returns
mixed

public static __callStatic ($name, $params)

Inherited from FormWidgetBase
Parameters
Property Description
$name
mixed
$params
mixed
Returns
mixed

public __construct ($controller, $formField, array $configuration = [])

Inherited from FormWidgetBase

Constructor

Parameters
Property Description
$controller
mixed

Controller Active controller object.

$formField
mixed

FormField Object containing general form field information.

$configuration
array

array Configuration the relates to this widget.

Returns
mixed

public __get ($name)

Inherited from FormWidgetBase
Parameters
Property Description
$name
mixed
Returns
mixed

public __set ($name, $value)

Inherited from FormWidgetBase
Parameters
Property Description
$name
mixed
$value
mixed
Returns
mixed

public addCss (array | string $name, array $attributes = []) : void

Inherited from FormWidgetBase

Adds StyleSheet asset to the asset list. Call $this->makeAssets() in a view to output corresponding markup.

Parameters
Property Description
$name
array | string

Specifies a path (URL) or an array of paths to the stylesheet(s).

$attributes
array

Adds extra HTML attributes to the asset link.

Returns
void

public addDynamicMethod (string $dynamicName, callable $method, string $extension = null)

Inherited from FormWidgetBase

Programmatically adds a method to the extendable class

Parameters
Property Description
$dynamicName
string
$method
callable
$extension
string
Returns
mixed

public addDynamicProperty (string $dynamicName, mixed $value = null) : void

Inherited from FormWidgetBase

Programmatically adds a property to the extendable class

Parameters
Property Description
$dynamicName
string

The name of the property to add

$value
mixed

The value of the property

Returns
void

public addJs (array | string $name, array $attributes = []) : void

Inherited from FormWidgetBase

Adds JavaScript asset to the asset list. Call $this->makeAssets() in a view to output corresponding markup.

Parameters
Property Description
$name
array | string

Specifies a path (URL) or an array of paths to the script(s).

$attributes
array

Adds extra HTML attributes to the asset link.

Returns
void

public addRss (string $name, array $attributes = []) : void

Inherited from FormWidgetBase

Adds an RSS link asset to the asset list. Call $this->makeAssets() in a view to output corresponding markup.

Parameters
Property Description
$name
string

Specifies a path (URL) to the RSS channel

$attributes
array

Adds extra HTML attributes to the asset link.

Returns
void

public addViewPath (string | array $path) : void

Inherited from FormWidgetBase

Prepends a path on the available view path locations.

Parameters
Property Description
$path
string | array
Returns
void

public asExtension (string $shortName) : mixed

Inherited from FormWidgetBase

Short hand for getClassExtension() method, except takes the short extension name, example:

$this->asExtension('FormController')

Parameters
Property Description
$shortName
string
Returns
mixed

public bindToController () : void

Inherited from FormWidgetBase

Binds a widget to the controller for safe use.

Returns
void

public static clearExtendedClasses () : void

Inherited from FormWidgetBase

Clear the list of extended classes so they will be re-extended.

Returns
void

public combineAssets (array $assets, string $localPath = "") : string

Inherited from FormWidgetBase

Run the provided assets through the Asset Combiner

Parameters
Property Description
$assets
array

Collection of assets

$localPath
string

Prefix all assets with this path (optional)

Returns
string

public extendClassWith (string $extensionName) : void

Inherited from FormWidgetBase

Dynamically extend a class with a specified behavior

Parameters
Property Description
$extensionName
string
Returns
void

public static extendableAddExtension (callable $callback, boolean $scoped = false, $outerScope = null) : void

Inherited from FormWidgetBase

Extends the class using a closure.

The closure will be provided a single parameter which is the instance of the extended class, by default.

You may optionally specify the callback as a scoped callback, which inherits the scope of the extended class and provides access to protected and private methods and properties. This makes any call using $this act on the extended class, not the class providing the extension.

If you use a scoped callback, you can provide the "outer" scope - or the scope of the class providing the extension, with the third parameter. The outer scope object will then be passed as the single parameter to the closure.

Parameters
Property Description
$callback
callable
$scoped
boolean
$outerScope
mixed
Returns
void

public extendableCall (string $name, array $params = null) : mixed

Inherited from FormWidgetBase

Magic method for __call().

Callback priority is as follows:

  • "Dynamic Methods" added locally to the object via addDynamicMethod($name, $callable)
  • Methods available on Behaviors that have been implemented by the object
  • Pass it to the parent's __call() method if it defines one
Parameters
Property Description
$name
string
$params
array
Returns
mixed

public static extendableCallStatic (string $name, array $params = null) : mixed

Inherited from FormWidgetBase

Magic method for __callStatic()

Parameters
Property Description
$name
string
$params
array
Returns
mixed

public extendableConstruct ()

Inherited from FormWidgetBase

This method should be called as part of the constructor.

Returns
mixed

public static extendableExtendCallback (callable $callback, boolean $scoped = false, $outerScope = null) : void

Inherited from FormWidgetBase

Helper method for ::extend() static method.

Parameters
Property Description
$callback
callable
$scoped
boolean
$outerScope
mixed
Returns
void

public extendableGet (string $name) : mixed | null

Inherited from FormWidgetBase

Magic method for __get()

Parameters
Property Description
$name
string
Returns
mixed | null

public extendableSet (string $name, mixed $value) : void

Inherited from FormWidgetBase

Magic method for __set()

Parameters
Property Description
$name
string
$value
mixed
Returns
void

public fireSystemEvent (string $event, array $params = [], boolean $halt = true) : mixed

Inherited from FormWidgetBase

Fires a combination of local and global events. The first segment is removed from the event name locally and the local object is passed as the first argument to the event globally. Halting is also enabled by default.

For example:

$this->fireSystemEvent('backend.list.myEvent', ['my value']);

Is equivalent to:

$this->fireEvent('list.myEvent', ['myvalue'], true);

Event::fire('backend.list.myEvent', [$this, 'myvalue'], true);
Parameters
Property Description
$event
string

Event name

$params
array

Event parameters

$halt
boolean

Halt after first non-null result

Returns
mixed

public fireViewEvent (string $event, array $params = []) : string

Inherited from FormWidgetBase

Special event function used for extending within view files, allowing HTML to be injected multiple times.

For example:

= $this->fireViewEvent('backend.auth.extendSigninView') ?>
Parameters
Property Description
$event
string

Event name

$params
array

Event parameters

Returns
string

public flushAssets () : void

Inherited from FormWidgetBase

Disables the use, and subequent broadcast, of assets. This is useful to call during an AJAX request to speed things up. This method works by specifically targeting the hasAssetsDefined method.

Returns
void

public getAssetPath (string $fileName, string $assetPath = null) : string

Inherited from FormWidgetBase

Locates a file based on it's definition. If the file starts with a forward slash, it will be returned in context of the application public path, otherwise it will be returned in context of the asset path.

Parameters
Property Description
$fileName
string

File to load.

$assetPath
string

Explicitly define an asset path.

Returns
string

Relative path to the asset file.

public getAssetPaths () : array

Inherited from FormWidgetBase

Returns an array of all registered asset paths.

Returns
array

public getClassExtension (string $name) : mixed

Inherited from FormWidgetBase

Returns a behavior object from an extendable class, example:

$this->getClassExtension('Backend.Behaviors.FormController')

Parameters
Property Description
$name
string

Fully qualified behavior name

Returns
mixed

public getClassMethods () : array

Inherited from FormWidgetBase

Get a list of class methods, extension equivalent of get_class_methods()

Returns
array

public getConfig (string $name, string $default = null) : string

Inherited from FormWidgetBase

Safe accessor for configuration values.

Parameters
Property Description
$name
string

Config name, supports array names like "field[key]"

$default
string

Default value if nothing is found

Returns
string

public getConfigPath (string $fileName, mixed $configPath = null) : string

Inherited from FormWidgetBase

Locates a file based on it's definition. If the file starts with the ~ symbol it will be returned in context of the application base path, otherwise it will be returned in context of the config path.

Parameters
Property Description
$fileName
string

File to load.

$configPath
mixed

Explicitly define a config path.

Returns
string

Full path to the config file.

public getController ()

Inherited from FormWidgetBase

Returns the controller using this widget.

Returns
mixed

public getDynamicProperties () : array

Inherited from FormWidgetBase

Returns all dynamic properties and their values

Returns
array

['property' => 'value']

public getEventHandler (string $name) : string

Inherited from FormWidgetBase

Returns a fully qualified event handler name for this widget.

Parameters
Property Description
$name
string

The ajax event handler name.

Returns
string

public getFatalError () : string

Inherited from FormWidgetBase
Returns
string

The fatal error message

public getFieldName () : string

Inherited from FormWidgetBase

Returns the HTML element field name for this widget, used for capturing user input, passed back to the getSaveValue method when saving.

Returns
string

HTML element name

public getId ($suffix = null)

Inherited from FormWidgetBase

Returns a unique ID for this widget. Useful in creating HTML markup.

Parameters
Property Description
$suffix
mixed
Returns
mixed

public getLoadValue () : string

Inherited from FormWidgetBase

Returns the value for this form field, supports nesting via HTML array.

Returns
string

public getParentForm () : Backend\Widgets\Form | null

Inherited from FormWidgetBase

Retrieve the parent form for this formwidget

Returns

public getViewPath (string $fileName, $viewPaths = null) : string

Inherited from FormWidgetBase

Locates a file based on its definition. The file name can be prefixed with a symbol (~|$) to return in context of the application or plugin base path, otherwise it will be returned in context of this object view path.

If the fileName cannot be found it will be returned unmodified.

Parameters
Property Description
$fileName
string
$viewPaths
mixed
Returns
string

public getViewPaths () : array

Inherited from FormWidgetBase

Returns the active view path locations.

Returns
array

public guessConfigPath (string $suffix = "") : string

Inherited from FormWidgetBase

Guess the package path for the called class.

Parameters
Property Description
$suffix
string

An extra path to attach to the end

Returns
string

public guessConfigPathFrom (string $class, string $suffix = "") : string

Inherited from FormWidgetBase

Guess the package path from a specified class.

Parameters
Property Description
$class
string

Class to guess path from.

$suffix
string

An extra path to attach to the end

Returns
string

public guessViewPath (string $suffix = "", boolean $isPublic = false) : string | null

Inherited from FormWidgetBase

Guess the package path for the called class.

Parameters
Property Description
$suffix
string

An extra path to attach to the end

$isPublic
boolean

Returns public path instead of an absolute one

Returns
string | null

public guessViewPathFrom (string $class, string $suffix = "", boolean $isPublic = false) : string | null

Inherited from FormWidgetBase

Guess the package path from a specified class.

Parameters
Property Description
$class
string

Class to guess path from.

$suffix
string

An extra path to attach to the end

$isPublic
boolean

Returns public path instead of an absolute one

Returns
string | null

public handleError ($exception)

Inherited from FormWidgetBase

Sets standard page variables in the case of a controller error.

Parameters
Property Description
$exception
mixed
Returns
mixed

public hasAssetsDefined () : bool

Inherited from FormWidgetBase

Returns true if assets any have been added.

Returns
bool

public hasFatalError () : bool

Inherited from FormWidgetBase
Returns
bool

Whether a fatal error has been set or not.

public isClassExtendedWith (string $name) : bool

Inherited from FormWidgetBase

Check if extendable class is extended with a behavior object

Parameters
Property Description
$name
string

Fully qualified behavior name

Returns
bool

public makeAssets ($type = null) : string | null

Inherited from FormWidgetBase

Outputs <link> and <script> tags to load assets previously added with addJs, addCss, & addRss method calls depending on the provided $type

Parameters
Property Description
$type
mixed
Returns
string | null

public makeConfig (array $configFile = [], array $requiredConfig = []) : array | stdClass

Inherited from FormWidgetBase

Reads the contents of the supplied file and applies it to this object.

Parameters
Property Description
$configFile
array
$requiredConfig
array
Returns
array | stdClass

public makeConfigFromArray (array $configArray = []) : stdClass

Inherited from FormWidgetBase

Makes a config object from an array, making the first level keys properties of a new object.

Parameters
Property Description
$configArray
array

Config array.

Returns
stdClass

The config object

public makeFileContents (string $filePath, array $extraParams = []) : string

Inherited from FormWidgetBase

Includes a file path using output buffering, making the provided vars available.

Parameters
Property Description
$filePath
string
$extraParams
array
Returns
string

public makeFormWidget (string $class, array $fieldConfig = [], array $widgetConfig = []) : Backend\Classes\FormWidgetBase

Inherited from FormWidgetBase

Makes a form widget object with the supplied form field and widget configuration.

Parameters
Property Description
$class
string

Widget class name

$fieldConfig
array

A field name, an array of config or a FormField object.

$widgetConfig
array

An array of config.

Returns

The widget object

public makeLayout ($name = null, array $params = [], boolean $throwException = true) : string | bool

Inherited from FormWidgetBase

Render a layout, defaulting to the layout propery specified on the class

Parameters
Property Description
$name
mixed
$params
array
$throwException
boolean
Returns
string | bool

The layout contents, or false.

public makeLayoutPartial (string $partial, array $params = []) : string

Inherited from FormWidgetBase

Renders a layout partial

Parameters
Property Description
$partial
string
$params
array
Returns
string

public makePartial (string $partial, array $params = [], boolean $throwException = true) : mixed

Inherited from FormWidgetBase

Render a partial file contents located in the views folder.

Parameters
Property Description
$partial
string
$params
array
$throwException
boolean
Returns
mixed

Partial contents or false if not throwing an exception.

public makeView (string $view) : string

Inherited from FormWidgetBase

Loads the specified view. Applies the layout if one is set.

The view file must have the .php extension (or ".htm" for historical reasons) and be located in the views directory

Parameters
Property Description
$view
string
Returns
string

public makeViewContent (string $contents, $layout = null) : string

Inherited from FormWidgetBase

Renders supplied contents inside a layout.

Parameters
Property Description
$contents
string
$layout
mixed
Returns
string

public makeWidget (string $class, array $widgetConfig = []) : mixed | Backend\Classes\WidgetBase

Inherited from FormWidgetBase

Makes a widget object with the supplied configuration file.

Parameters
Property Description
$class
string

Widget class name

$widgetConfig
array

An array of config.

Returns

The widget object

public mergeConfig (mixed $configA, mixed $configB) : stdClass

Inherited from FormWidgetBase

Merges two configuration sources, either prepared or not, and returns them as a single configuration object.

Parameters
Property Description
$configA
mixed
$configB
mixed
Returns
stdClass

The config object

public methodExists (string $name) : bool

Inherited from FormWidgetBase

Checks if a method exists, extension equivalent of method_exists()

Parameters
Property Description
$name
string
Returns
bool

public propertyExists (string $name) : bool

Inherited from FormWidgetBase

Checks if a property exists, extension equivalent of property_exists()

Parameters
Property Description
$name
string
Returns
bool

public resetSession () : void

Inherited from FormWidgetBase

Resets all session data related to this widget.

Returns
void

protected addAsset (string $type, string $path, array $attributes)

Inherited from FormWidgetBase

Adds the provided asset to the internal asset collections

Parameters
Property Description
$type
string

The type of the asset: 'js' || 'css' || 'rss'

$path
string

The path to the asset

$attributes
array

The attributes for the asset

Returns
mixed

protected extendableAddLocalExtension (Closure $callback, $outerScope = null)

Inherited from FormWidgetBase

Adds local extensibility to the current instance.

This rebinds a given closure to the current instance, making it able to access protected and private methods. This makes any call using $this within the closure act on the extended class, not the class providing the extension.

An outer scope may be provided by providing a second parameter, which will then be passed through to the closure as its first parameter. If this is not given, the current instance will be provided as the first parameter.

Parameters
Property Description
$callback
Closure
$outerScope
mixed
Returns
mixed

protected extendableIsAccessible (mixed $class, string $propertyName) : bool

Inherited from FormWidgetBase

Checks if a property is accessible, property equivalent of is_callable()

Parameters
Property Description
$class
mixed
$propertyName
string
Returns
bool

protected extensionExtractMethods (string $extensionName, object $extensionObject) : void

Inherited from FormWidgetBase

Extracts the available methods from a behavior and adds it to the list of callable methods.

Parameters
Property Description
$extensionName
string
$extensionObject
object
Returns
void

protected extensionGetClassLoader () : Winter\Storm\Support\ClassLoader | null

Inherited from FormWidgetBase

Gets the class loader

Returns
Winter\Storm\Support\ClassLoader | null

protected extensionNormalizeClassName (string $name) : string

Inherited from FormWidgetBase

Normalizes the provided extension name allowing for the ClassLoader to inject aliased classes

Parameters
Property Description
$name
string
Returns
string

protected fillFromConfig (array $properties = null) : void

Inherited from FormWidgetBase

Transfers config values stored inside the $config property directly on to the root object properties. If no properties are defined all config will be transferred if it finds a matching property.

Parameters
Property Description
$properties
array
Returns
void

protected getAssetEntryBuildPath (array $asset) : string

Inherited from FormWidgetBase

Internal helper, attaches a build code to an asset path

Parameters
Property Description
$asset
array

Stored asset array

Returns
string

protected getAssetScheme (string $asset) : string

Inherited from FormWidgetBase

Internal helper, get asset scheme

Parameters
Property Description
$asset
string

Specifies a path (URL) to the asset.

Returns
string

protected getLocalPath (string | null $relativePath)

Inherited from FormWidgetBase
Parameters
Property Description
$relativePath
string | null
Returns
mixed

protected getSession (string $key = null, string $default = null) : string

Inherited from FormWidgetBase

Retrieves a widget related key/value pair from session data.

Parameters
Property Description
$key
string

Unique key for the data store.

$default
string

A default value to use when value is not found.

Returns
string

protected handleViewException (Throwable $e, integer $obLevel) : void

Inherited from FormWidgetBase

Handle a view exception.

Parameters
Property Description
$e
Throwable
$obLevel
integer
Returns
void

protected makeSessionId () : string

Inherited from FormWidgetBase

Returns a unique session identifier for this widget and controller action.

Returns
string

protected putSession (string $key, mixed $value) : void

Inherited from FormWidgetBase

Saves a widget related key/value pair in to session data.

Parameters
Property Description
$key
string

Unique key for the data store.

$value
mixed

The value to store.

Returns
void

protected removeDuplicates () : void

Inherited from FormWidgetBase

Removes duplicate assets from the entire collection.

Returns
void
Copyright © 2024 Winter CMS