PHP code example of nonameffh / yii2-x-editable
1. Go to this page and download the library: Download nonameffh/yii2-x-editable library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
nonameffh / yii2-x-editable example snippets
use mcms\xeditable\XEditable;
$model = Model::findOne($id);
public function actions()
{
return [
'editable' => [
'class' => 'mcms\xeditable\XEditableAction',
//'scenario'=>'editable', //optional
'modelclass' => Model::className(),
],
];
}
echo XEditable::widget([
'value' => 'With Xeditable'
]);
echo '<br>';
echo \mcms\xeditable\XEditableText::widget([
'value' => 'With XEditableText'
]);
echo \mcms\xeditable\XEditableText::widget([
'model' => $model,
'placement' => 'right',
'pluginOptions' => [
'name' => 'title',
],
'callbacks' => [
'validate' => new \yii\web\JsExpression('
function(value) {
if($.trim(value) == "") {
return "This field is
echo \mcms\xeditable\XEditableText::widget([
'model' => $model,
'placement' => 'right',
'pluginOptions' => [
'toggle' => 'manual',
'name' => 'title',
],
'callbacks' => [
'validate' => new \yii\web\JsExpression('
function(value) {
if($.trim(value) == "") {
return "This field is
echo \mcms\xeditable\XEditableTextArea::widget([
'model' => $model,
'placement' => 'right',
'pluginOptions' => [
'name' => 'content',
],
]);
echo \mcms\xeditable\XEditableSelect::widget([
'model' => $model,
'placement' => 'right',
'pluginOptions' => [
'name' => 'status',
'source'=>[
['value'=>1,
'text'=>Yii::t('app','On')],
['value'=>0,
'text'=>Yii::t('app','Off')]
],
],
]);
echo \mcms\xeditable\XEditableDate::widget([
'model' => $model,
'placement' => 'right',
'pluginOptions' => [
'name' => 'created_at',
'value' => date('Y-m-d',$model->created_at),
'format' => 'yyyy-mm-dd',
'viewformat' => 'dd/mm/yyyy',
'datepicker' => [
[
'weekStart' => 1
]
],
]
]);
echo \mcms\xeditable\XEditableCheckList::widget([
'model' => $model,
'placement' => 'right',
'pluginOptions' => [
'name' => 'image',
'source'=>[
['value'=>'option1',
'text'=>Yii::t('app','option1')],
['value'=>'option2',
'text'=>Yii::t('app','option2')],
['value'=>'option3',
'text'=>Yii::t('app','option3')]
],
],
]);
echo \mcms\xeditable\XEditableWysiHtml5::widget([
'type' => 'wysihtml5',
'model' => $model,
'pluginOptions' => [
'toggle' => 'manual',
'name' => 'content',
'title' => 'Enter comments',
],
]);