PHP Класс WhEditable

Creates editable element on page (without linking to model attribute)
Автор: Antonio Ramirez ([email protected])
Автор: Vitaliy Potapov ([email protected])
Наследование: extends CWidget
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$apply whether to apply 'editable' js plugin to element. Only **safe** attributes become editable.
$combodate full config for **combodate** input. For details see http://vitalets.github.com/combodate/#docs
$disabled will editable be initially disabled. It means editable plugin will be applied to element, but you should call .editable('enable') method to activate it. To totally disable applying 'editable' to element use **apply** option.
$display string Example:
'display' => 'js: function(value, sourceData) {
     var escapedValue = $("<div>").text(value).html();
     $(this).html("<b>"+escapedValue+"</b>");
}'
$emptytext text shown on empty field. If null - default X-editable value is used: Empty
$encode whether to HTML encode text on output
$format format to send date on server. If null - default X-editable value is used: yyyy-mm-dd.
$htmlOptions HTML options of element. In EditableColumn htmlOptions are PHP expressions so you can use $data to bind values to particular cell, e.g. 'data-categoryID' => '$data->categoryID'.
$inputclass css class of input. If null - default X-editable value is used: input-medium
$liveSelector string Usefull in combination of liveTarget when you want to keep field(s) editble after ajaxUpdate
$liveTarget string DOM id of target where afterAjaxUpdate handler will call live update of editable element
$mode mode of input: inline | popup. If not set - default X-editable value is used: popup.
$name name of field
$onHidden string A javascript function that will be invoked when editable form is hidden Example:
'onHidden' => 'js: function(e, reason) {
   if(reason === "save" || reason === "cancel") {
auto-open next editable
       $(this).closest("tr").next().find(".editable").editable("show");
   }
}'
$onInit string A javascript function that will be invoked when editable element is initialized
$onSave string A javascript function that will be invoked when new value is saved Example:
'onSave' => 'js: function(e, params) {
    alert("Saved value: " + params.newValue);
}'
$onShown string A javascript function that will be invoked when editable form is shown Example:
'onShown' => 'js: function() {
    var $tip = $(this).data("editableContainer").tip();
    $tip.find("input").val("overwriting value of input.");
}'
$options all config options of x-editable. See full list here.
$params additional params to send on server
$pk primary key
$placement placement of popup. Can be left, top, right, bottom. If null - default X-editable value is used: top
$select2 full config for **select2** input. For details see http://ivaynberg.github.com/select2
$send Strategy for sending data on server. Can be auto|always|never. When 'auto' data will be sent on server only if **pk** and **url** defined, otherwise new value will be stored locally.
$showbuttons visibility of buttons. Can be boolean false|true or string bottom.
$source source data for **select**, **checklist**. Can be string (url) or array in format: array( array("value" => 1, "text" => "abc"), ...)
$success string Example:
'success' => 'js: function(response, newValue) {
    if(!response.success) return response.msg;
}'
$template template for **combodate** input. For details see http://vitalets.github.com/x-editable/docs.html#combodate.
$text text to be shown as element content
$theme for jQuery UI only. The JUI theme name.
$title title of popup. If null - will be generated automatically from attribute label. Can have token {label} inside that will be replaced with actual attribute label.
$type type of editable widget. Can be text, textarea, select, date, checklist, etc.
$url url to submit value. Can be string or array containing Yii route, e.g. array('site/updateUser')
$validate string Example:
'validate' => 'js: function(value) {
    if($.trim(value) == "") return "This field is required";
}'
$value initial value. If not set - will be taken from text
$viewformat format to display date in element. If null - equals to **format** option.
$viewseparator separator used to display tags.

Защищенные свойства (Protected)

Свойство Тип Описание
$_prepareToAutotext

Открытые методы

Метод Описание
attachAjaxUpdateEvent ( mixed $widget ) injects ajaxUpdate event into widget
buildHtmlOptions ( ) Builds html options
buildJsOptions ( ) Builds javascript options
getSelector ( ) : null | string Returns the plugin selector
init ( ) initialization of widget
isAutotext ( mixed $options, mixed $type ) : boolean Returns is autotext should be applied to widget: e.g. for 'select' to display text for id
registerAssets ( ) Registers assets
registerClientScript ( ) : string Registers client script
renderLink ( ) Renders a link
renderText ( ) Renders text
run ( ) Widget run method
source ( mixed $models, mixed $valueField = '', mixed $textField = '', mixed $groupField = '', mixed $groupTextField = '' ) : array Returns php-array as valid x-editable source in format: [{value: 1, text: 'text1'}, {.

Описание методов

attachAjaxUpdateEvent() публичный статический Метод

injects ajaxUpdate event into widget
public static attachAjaxUpdateEvent ( mixed $widget )
$widget mixed

buildHtmlOptions() публичный Метод

Builds html options
public buildHtmlOptions ( )

buildJsOptions() публичный Метод

Builds javascript options
public buildJsOptions ( )

getSelector() публичный Метод

Returns the plugin selector
public getSelector ( ) : null | string
Результат null | string

init() публичный Метод

initialization of widget
public init ( )

isAutotext() публичный статический Метод

Returns is autotext should be applied to widget: e.g. for 'select' to display text for id
public static isAutotext ( mixed $options, mixed $type ) : boolean
$options mixed
$type mixed
Результат boolean

registerAssets() публичный Метод

Registers assets
public registerAssets ( )

registerClientScript() публичный Метод

Registers client script
public registerClientScript ( ) : string
Результат string

renderText() публичный Метод

Renders text
public renderText ( )

run() публичный Метод

Widget run method
public run ( )

source() публичный статический Метод

..}] See https://github.com/vitalets/x-editable-yii/issues/37
public static source ( mixed $models, mixed $valueField = '', mixed $textField = '', mixed $groupField = '', mixed $groupTextField = '' ) : array
$models mixed
$valueField mixed
$textField mixed
$groupField mixed
$groupTextField mixed
Результат array

Описание свойств

$_prepareToAutotext защищенное свойство

protected $_prepareToAutotext

$apply публичное свойство

whether to apply 'editable' js plugin to element. Only **safe** attributes become editable.
public $apply

$combodate публичное свойство

full config for **combodate** input. For details see http://vitalets.github.com/combodate/#docs
public $combodate

$disabled публичное свойство

will editable be initially disabled. It means editable plugin will be applied to element, but you should call .editable('enable') method to activate it. To totally disable applying 'editable' to element use **apply** option.
public $disabled

$display публичное свойство

Example:
'display' => 'js: function(value, sourceData) {
     var escapedValue = $("<div>").text(value).html();
     $(this).html("<b>"+escapedValue+"</b>");
}'
public string $display
Результат string

$emptytext публичное свойство

text shown on empty field. If null - default X-editable value is used: Empty
public $emptytext

$encode публичное свойство

whether to HTML encode text on output
public $encode

$format публичное свойство

format to send date on server. If null - default X-editable value is used: yyyy-mm-dd.
public $format

$htmlOptions публичное свойство

HTML options of element. In EditableColumn htmlOptions are PHP expressions so you can use $data to bind values to particular cell, e.g. 'data-categoryID' => '$data->categoryID'.
public $htmlOptions

$inputclass публичное свойство

css class of input. If null - default X-editable value is used: input-medium
public $inputclass

$liveSelector публичное свойство

Usefull in combination of liveTarget when you want to keep field(s) editble after ajaxUpdate
public string $liveSelector
Результат string

$liveTarget публичное свойство

DOM id of target where afterAjaxUpdate handler will call live update of editable element
public string $liveTarget
Результат string

$mode публичное свойство

mode of input: inline | popup. If not set - default X-editable value is used: popup.
public $mode

$name публичное свойство

name of field
public $name

$onHidden публичное свойство

A javascript function that will be invoked when editable form is hidden Example:
'onHidden' => 'js: function(e, reason) {
   if(reason === "save" || reason === "cancel") {
auto-open next editable
       $(this).closest("tr").next().find(".editable").editable("show");
   }
}'
public string $onHidden
Результат string

$onInit публичное свойство

A javascript function that will be invoked when editable element is initialized
public string $onInit
Результат string

$onSave публичное свойство

A javascript function that will be invoked when new value is saved Example:
'onSave' => 'js: function(e, params) {
    alert("Saved value: " + params.newValue);
}'
public string $onSave
Результат string

$onShown публичное свойство

A javascript function that will be invoked when editable form is shown Example:
'onShown' => 'js: function() {
    var $tip = $(this).data("editableContainer").tip();
    $tip.find("input").val("overwriting value of input.");
}'
public string $onShown
Результат string

$options публичное свойство

all config options of x-editable. See full list here.
public $options

$params публичное свойство

additional params to send on server
public $params

$pk публичное свойство

primary key
public $pk

$placement публичное свойство

placement of popup. Can be left, top, right, bottom. If null - default X-editable value is used: top
public $placement

$select2 публичное свойство

full config for **select2** input. For details see http://ivaynberg.github.com/select2
public $select2

$send публичное свойство

Strategy for sending data on server. Can be auto|always|never. When 'auto' data will be sent on server only if **pk** and **url** defined, otherwise new value will be stored locally.
public $send

$showbuttons публичное свойство

visibility of buttons. Can be boolean false|true or string bottom.
public $showbuttons

$source публичное свойство

source data for **select**, **checklist**. Can be string (url) or array in format: array( array("value" => 1, "text" => "abc"), ...)
public $source

$success публичное свойство

Example:
'success' => 'js: function(response, newValue) {
    if(!response.success) return response.msg;
}'
public string $success
Результат string

$template публичное свойство

template for **combodate** input. For details see http://vitalets.github.com/x-editable/docs.html#combodate.
public $template

$text публичное свойство

text to be shown as element content
public $text

$theme публичное свойство

for jQuery UI only. The JUI theme name.
public $theme

$title публичное свойство

title of popup. If null - will be generated automatically from attribute label. Can have token {label} inside that will be replaced with actual attribute label.
public $title

$type публичное свойство

type of editable widget. Can be text, textarea, select, date, checklist, etc.
public $type

$url публичное свойство

url to submit value. Can be string or array containing Yii route, e.g. array('site/updateUser')
public $url

$validate публичное свойство

Example:
'validate' => 'js: function(value) {
    if($.trim(value) == "") return "This field is required";
}'
public string $validate
Результат string

$value публичное свойство

initial value. If not set - will be taken from text
public $value

$viewformat публичное свойство

format to display date in element. If null - equals to **format** option.
public $viewformat

$viewseparator публичное свойство

separator used to display tags.
public $viewseparator