ColorPicker PHP Class Overview
The Kendo UI ColorPicker for PHP is a server-side wrapper for the Kendo UI ColorPicker widget.
The ColorPicker is part of Telerik UI for PHP, a
professional grade UI library with 90+ components for building modern and feature-rich applications. To try it out sign up for a free 30-day trial.
Getting Started
Configuration
Below are listed the steps for you to follow when configuring the Kendo UI ColorPicker for PHP.
Step 1 Make sure you followed all the steps from the introductory article on Telerik UI for PHP—include the autoloader, JavaScript, and CSS files.
Step 2 Create a ColorPicker.
<?php
$colorpicker = new \Kendo\UI\ColorPicker('colorpicker');
$colorpicker->value('#ff0000');
?>
Step 3 Output the ColorPicker by echoing the result of the render
method.
<?php
echo $colorpicker->render();
?>
Event Handling
You can subscribe to all ColorPicker events.
Specify Function Names
The example below demonstrates how to subscribe for events by specifying a JavaScript function name.
<?php $colorpicker = new \Kendo\UI\ColorPicker('colorpicker');
// The 'colorpicker_change' JavaScript function will handle the 'change' event of the colorpicker
$colorpicker->change('colorpicker_change');
echo $colorpicker->render();
?>
<script>
function colorpicker_change() {
// Handle the change event
}
</script>
Provide Inline Code
The example below demonstrates how to subscribe to events by providing inline JavaScript code.
<?php
$colorpicker = new \Kendo\UI\ColorPicker('colorpicker');
// Provide inline JavaScript code that will handle the 'change' event of the colorpicker
$colorpicker->change('function() { /* Handle the change event */ }');
echo $colorpicker->render();
?>
Reference
Client-Side Instances
You are able to reference an existing ColorPicker instance via the jQuery.data()
. Once a reference is established, use the ColorPicker API to control its behavior.
<?php
$colorpicker = new \Kendo\UI\ColorPicker('colorpicker');
echo $colorpicker->render();
?>
<script>
$(function() {
// The constructor parameter is used as the 'id' HTML attribute of the colorpicker
var colorpicker = $("#colorpicker").data("kendoColorPicker")
});
</script>