\Kendo\UI\SwitchButton

A PHP wrapper for Kendo UI Switch.

Inherits from \Kendo\UI\Widget.

Usage

To use SwitchButton in a PHP page instantiate a new instance, configure it via the available configuration methods and output it by echo-ing the result of the render method.

Using Kendo SwitchButton

<?php
// Create a new instance of SwitchButton and specify its id
$switch = new \Kendo\UI\SwitchButton('Switch');

// Configure it
$switch->checked(true)

// Output it

echo $switch->render();
?>

Methods

change

Fires when the checked state of the Switch is changed through user interaction. For additional information check the change event documentation.

Returns

\Kendo\UI\SwitchButton

Parameters

$value string|\Kendo\JavaScriptFunction

Example - using string which defines a JavaScript function

<?php
$switch = new \Kendo\UI\SwitchButton('Switch');
$switch->change('function(e) { }');
?>

Example - using string which defines a JavaScript name

<script>
    function onChange(e) {
        // handle the change event.
    }
</script>
<?php
$switch = new \Kendo\UI\SwitchButton('Switch');
$switch->change('onChange');
?>

Example - using \Kendo\JavaScriptFunction

<?php
$switch = new \Kendo\UI\SwitchButton('Switch');
$switch->change(new \Kendo\JavaScriptFunction('function(e) { }'));
?>

checked

The checked state of the Switch.

Returns

\Kendo\UI\SwitchButton

Parameters

$value boolean

Example

<?php
$switch = new \Kendo\UI\SwitchButton('Switch');
$switch->checked(true);
?>

enabled

If set to false, the Switch will be disabled and will not allow the user to change its checked state.

Returns

\Kendo\UI\SwitchButton

Parameters

$value boolean

Example

<?php
$switch = new \Kendo\UI\SwitchButton('Switch');
$switch->enabled(true);
?>

messages

Defines the text of the checked and unchecked labels that are displayed within the Switch. All labels support localization.

Returns

\Kendo\UI\SwitchButton

Parameters

$value \Kendo\UI\SwitchButtonMessages|array

Example - using \Kendo\UI\SwitchButtonMessages

<?php
$switch = new \Kendo\UI\SwitchButton('Switch');
$messages = new \Kendo\UI\SwitchButtonMessages();
$checked = 'value';
$messages->checked($checked);
$switch->messages($messages);
?>

Example - using array

<?php
$switch = new \Kendo\UI\SwitchButton('Switch');
$checked = 'value';
$switch->messages(array('checked' => $checked));
?>

readonly

If set to true, the Switch will render into its read-only state.

Returns

\Kendo\UI\SwitchButton

Parameters

$value boolean

Example

<?php
$switch = new \Kendo\UI\SwitchButton('Switch');
$switch->readonly(true);
?>

size

Sets a value controlling the size of the component. Can also be set to the following string values: "small"; "medium"; "large" or "none".

Returns

\Kendo\UI\SwitchButton

Parameters

$value string

Example

<?php
$switch = new \Kendo\UI\SwitchButton('Switch');
$switch->size('value');
?>

thumbRounded

Sets a value controlling the thumb's border radius. Can also be set to the following string values: "small"; "medium"; "large"; "full" or "none".

Returns

\Kendo\UI\SwitchButton

Parameters

$value string

Example

<?php
$switch = new \Kendo\UI\SwitchButton('Switch');
$switch->thumbRounded('value');
?>

trackRounded

Sets a value controlling the track's border radius. Can also be set to the following string values: "small"; "medium"; "large"; "full" or "none".

Returns

\Kendo\UI\SwitchButton

Parameters

$value string

Example

<?php
$switch = new \Kendo\UI\SwitchButton('Switch');
$switch->trackRounded('value');
?>

width

The width of the Switch.

Returns

\Kendo\UI\SwitchButton

Parameters

$value float|string

Example - using float

<?php
$switch = new \Kendo\UI\SwitchButton('Switch');
$switch->width(1);
?>

Example - using string

<?php
$switch = new \Kendo\UI\SwitchButton('Switch');
$switch->width('value');
?>
In this article
Not finding the help you need?