\Kendo\UI\Form

A PHP wrapper for Kendo UI Form.

Inherits from \Kendo\UI\Widget.

Usage

To use Form 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 Form

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

// Configure it
$form->focusFirst(true)

// Output it

echo $form->render();
?>

Methods

buttonsTemplate

Specifies the template which is used for rendering the Form buttons.

Returns

\Kendo\UI\Form

Parameters

$value string|\Kendo\JavaScriptFunction

Example - using string

<?php
$form = new \Kendo\UI\Form('Form');
$form->buttonsTemplate('value');
?>

Example - using \Kendo\JavaScriptFunction

<?php
$form = new \Kendo\UI\Form('Form');
$form->buttonsTemplate(new \Kendo\JavaScriptFunction('function() { }'));
?>

change

Triggered when the form model is updated. For additional information check the change event documentation.

Returns

\Kendo\UI\Form

Parameters

$value string|\Kendo\JavaScriptFunction

Example - using string which defines a JavaScript function

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

Example - using string which defines a JavaScript name

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

Example - using \Kendo\JavaScriptFunction

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

clear

Triggered when the form is cleared. For additional information check the clear event documentation.

Returns

\Kendo\UI\Form

Parameters

$value string|\Kendo\JavaScriptFunction

Example - using string which defines a JavaScript function

<?php
$form = new \Kendo\UI\Form('Form');
$form->clear('function(e) { }');
?>

Example - using string which defines a JavaScript name

<script>
    function onClear(e) {
        // handle the clear event.
    }
</script>
<?php
$form = new \Kendo\UI\Form('Form');
$form->clear('onClear');
?>

Example - using \Kendo\JavaScriptFunction

<?php
$form = new \Kendo\UI\Form('Form');
$form->clear(new \Kendo\JavaScriptFunction('function(e) { }'));
?>

focusFirst

Specifies if the first editor of the form will be focused on initialization.

Returns

\Kendo\UI\Form

Parameters

$value boolean

Example

<?php
$form = new \Kendo\UI\Form('Form');
$form->focusFirst(true);
?>

formData

Provides the data model of the Form.The widget renders the form fields based on their data type, unless the items option is specified.

Returns

\Kendo\UI\Form

Parameters

$value ``

formatLabel

Callback function that could be used to change the default format of the automatically generated labels.

Returns

\Kendo\UI\Form

Parameters

$value \Kendo\JavaScriptFunction

Example

<?php
$form = new \Kendo\UI\Form('Form');
$form->formatLabel(new \Kendo\JavaScriptFunction('function() { }'));
?>

grid

Grid layout settings.

Returns

\Kendo\UI\Form

Parameters

$value \Kendo\UI\FormGrid|array

Example - using \Kendo\UI\FormGrid

<?php
$form = new \Kendo\UI\Form('Form');
$grid = new \Kendo\UI\FormGrid();
$cols = 1;
$grid->cols($cols);
$form->grid($grid);
?>

Example - using array

<?php
$form = new \Kendo\UI\Form('Form');
$cols = 1;
$form->grid(array('cols' => $cols));
?>

addItem

Adds one or more FormItem to the Form.

Returns

\Kendo\UI\Form

Parameters

$value[, $value2, ...] \Kendo\UI\FormItem|array

Example - using \Kendo\UI\FormItem

<?php
$form = new \Kendo\UI\Form('Form');
$item = new \Kendo\UI\FormItem();
$colSpan = 1;
$item->colSpan($colSpan);
$form->addItem($item);
?>

Example - using array

<?php
$form = new \Kendo\UI\Form('Form');
$colSpan = 1;
$form->addItem(array('colSpan' => $colSpan));
?>

Example - adding more than one FormItem

<?php
$form = new \Kendo\UI\Form('Form');
$first  = new \Kendo\UI\FormItem();
$second = new \Kendo\UI\FormItem();
$form->addItem($first, $second);
?>

layout

Specify the layout of Form content. Valid options are: grid: This is equivalent to display: grid. It defines the form element as a grid container and establishes a new grid formatting context for its contents..

Returns

\Kendo\UI\Form

Parameters

$value string

Example

<?php
$form = new \Kendo\UI\Form('Form');
$form->layout('value');
?>

messages

Configures text messages displayed in the Form. Use it to customize or localize the Form messages.

Returns

\Kendo\UI\Form

Parameters

$value \Kendo\UI\FormMessages|array

Example - using \Kendo\UI\FormMessages

<?php
$form = new \Kendo\UI\Form('Form');
$messages = new \Kendo\UI\FormMessages();
$clear = 'value';
$messages->clear($clear);
$form->messages($messages);
?>

Example - using array

<?php
$form = new \Kendo\UI\Form('Form');
$clear = 'value';
$form->messages(array('clear' => $clear));
?>

orientation

Configures the Form orientation. Available options are "horizontal" and "vertical".By default, the Form is rendered with vertical orientation.

Returns

\Kendo\UI\Form

Parameters

$value string

Example

<?php
$form = new \Kendo\UI\Form('Form');
$form->orientation('value');
?>

size

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

Returns

\Kendo\UI\Form

Parameters

$value string

Example

<?php
$form = new \Kendo\UI\Form('Form');
$form->size('value');
?>

submit

Triggered when the form is submitted. For additional information check the submit event documentation.

Returns

\Kendo\UI\Form

Parameters

$value string|\Kendo\JavaScriptFunction

Example - using string which defines a JavaScript function

<?php
$form = new \Kendo\UI\Form('Form');
$form->submit('function(e) { }');
?>

Example - using string which defines a JavaScript name

<script>
    function onSubmit(e) {
        // handle the submit event.
    }
</script>
<?php
$form = new \Kendo\UI\Form('Form');
$form->submit('onSubmit');
?>

Example - using \Kendo\JavaScriptFunction

<?php
$form = new \Kendo\UI\Form('Form');
$form->submit(new \Kendo\JavaScriptFunction('function(e) { }'));
?>

validatable

Configures the built-in Validator options.

Returns

\Kendo\UI\Form

Parameters

$value \Kendo\UI\FormValidatable|array

Example - using \Kendo\UI\FormValidatable

<?php
$form = new \Kendo\UI\Form('Form');
$validatable = new \Kendo\UI\FormValidatable();
$validateOnBlur = true;
$validatable->validateOnBlur($validateOnBlur);
$form->validatable($validatable);
?>

Example - using array

<?php
$form = new \Kendo\UI\Form('Form');
$validateOnBlur = true;
$form->validatable(array('validateOnBlur' => $validateOnBlur));
?>

validate

Fired when the validation of the entire form completes. For additional information check the validate event documentation.

Returns

\Kendo\UI\Form

Parameters

$value string|\Kendo\JavaScriptFunction

Example - using string which defines a JavaScript function

<?php
$form = new \Kendo\UI\Form('Form');
$form->validate('function(e) { }');
?>

Example - using string which defines a JavaScript name

<script>
    function onValidate(e) {
        // handle the validate event.
    }
</script>
<?php
$form = new \Kendo\UI\Form('Form');
$form->validate('onValidate');
?>

Example - using \Kendo\JavaScriptFunction

<?php
$form = new \Kendo\UI\Form('Form');
$form->validate(new \Kendo\JavaScriptFunction('function(e) { }'));
?>

validateField

Fired when the validation state of a field changes. For additional information check the validateField event documentation.

Returns

\Kendo\UI\Form

Parameters

$value string|\Kendo\JavaScriptFunction

Example - using string which defines a JavaScript function

<?php
$form = new \Kendo\UI\Form('Form');
$form->validateField('function(e) { }');
?>

Example - using string which defines a JavaScript name

<script>
    function onValidateField(e) {
        // handle the validateField event.
    }
</script>
<?php
$form = new \Kendo\UI\Form('Form');
$form->validateField('onValidateField');
?>

Example - using \Kendo\JavaScriptFunction

<?php
$form = new \Kendo\UI\Form('Form');
$form->validateField(new \Kendo\JavaScriptFunction('function(e) { }'));
?>
In this article
Not finding the help you need?