marciocamello/yii2-x-editable
Composer 安装命令:
composer require marciocamello/yii2-x-editable
包简介
X-editable extensions for Yii 2, based in X-editable with Bootstrap
关键字:
README 文档
README
X-editable extensions for Yii 2, based in X-editable 1.5.1 with Bootstrap 3 Link from project - http://vitalets.github.io/x-editable/
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require marciocamello/yii2-x-editable "dev-master"
or add
"marciocamello/yii2-x-editable": "*"
to the require section of your composer.json file.
Usage
Once the extension is installed, simply use it in your code by :
XEditable NameSpace and Model params
<?php use mcms\xeditable\XEditable; $model = Model::findOne($id); ?>
Actions
public function actions()
{
return [
'editable' => [
'class' => 'mcms\xeditable\XEditableAction',
//'scenario'=>'editable', //optional
'modelclass' => Model::className(),
],
];
}
Text whitout model
<?php
echo XEditable::widget([
'value' => 'With Xeditable'
]);
echo '<br>';
echo \mcms\xeditable\XEditableText::widget([
'value' => 'With XEditableText'
]);
?>
Text
<?php
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 required";
}
}
')
]
]);
?>
Text Toggle Manual
<?php
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 required";
}
}
')
]
]);
?>
TextArea
<?php
echo \mcms\xeditable\XEditableTextArea::widget([
'model' => $model,
'placement' => 'right',
'pluginOptions' => [
'name' => 'content',
],
]);
?>
Select
<?php
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')]
],
],
]); ?>
Date
<?php
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
]
],
]
]); ?>
DateTime
<?php
echo \mcms\xeditable\XEditableDateTime::widget([
'model' => $model,
'placement' => 'right',
'pluginOptions' => [
'name' => 'created_at',
'value' => date('Y-m-d h:i',$model->created_at),
'format' => 'yyyy-mm-dd hh:ii',
'viewformat' => 'dd/mm/yyyy hh:ii',
'datepicker' => [
[
'weekStart' => 1
]
],
]
]); ?>
ComboDate
<?php
echo \mcms\xeditable\XEditableComboDate::widget([
'model' => $model,
'placement' => 'right',
'type' => 'combodate',
'pluginOptions' => [
'name' => 'created_at',
'value' => date('Y-m-d h:i',$model->created_at),
'format' => 'YYYY-MM-DD HH:mm',
'viewformat' => 'MMM DD, YYYY HH:mm',
'template' => 'DD / MMM / YYYY HH:mm',
'combodate' => [
[
'minYear' => '2000',
'maxYear' => '2015',
'minuteStep' => '1'
]
],
]
]); ?>
Checklist
<?php
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')]
],
],
]); ?>
HTML Editor - WysiHtml5
<?php
echo \mcms\xeditable\XEditableWysiHtml5::widget([
'type' => 'wysihtml5',
'model' => $model,
'pluginOptions' => [
'toggle' => 'manual',
'name' => 'content',
'title' => 'Enter comments',
],
]); ?>
DataGrid
<?php
$provider = new \yii\data\ActiveDataProvider([
'query' => \backend\modules\cms\models\Categories::find(),
'pagination' => [
'pageSize' => 4,
],
]);
echo GridView::widget([
'id' => Yii::$app->controller->id,
'dataProvider' => $provider,
'columns' => [
[
'value'=>function($model) {
return $model->active;
},
'class' => \mcms\xeditable\XEditableColumn::className(),
'url' => 'editable',
'dataType'=>'select',
'editable'=>[
'source'=>[
['value'=>1,
'text'=>Yii::t('app','On')],
['value'=>0,
'text'=>Yii::t('app','Off')]
],
'placement' => 'right',
],
'attribute' => 'status',
'format' => 'raw',
],
'title',
]
]);
?>
Select2
<?php
$items = [
['value'=>'gb',
'text'=>Yii::t('app','Great Britain')],
['value'=>'us',
'text'=>Yii::t('app','United States')],
['value'=>'ru',
'text'=>Yii::t('app','Russia')]
];
echo XEditable::widget([
'placement' => 'right',
'type' => 'select2',
'pluginOptions' => [
'value' => 'ru',
'source'=> $items,
'select2' => [
'multiple' => true
],
]
]); ?>
TypeAheadJs
<?php
$items = [
['value'=>'gb',
'text'=>Yii::t('app','Great Britain')],
['value'=>'us',
'text'=>Yii::t('app','United States')],
['value'=>'ru',
'text'=>Yii::t('app','Russia')]
];
echo XEditable::widget([
'placement' => 'right',
'type' => 'typeaheadjs',
'pluginOptions' => [
'value' => 'ru',
'typeahead' => [
'name' => 'country',
'local' => $items,
],
]
]); ?>
marciocamello/yii2-x-editable 适用场景与选型建议
marciocamello/yii2-x-editable 是一款 基于 JavaScript 开发的 Composer 扩展包,目前已累计 8.93k 次下载、GitHub Stars 达 22, 最近一次更新时间为 2014 年 03 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「extension」 「yii2」 「x-editable」 「mcms」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 marciocamello/yii2-x-editable 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 marciocamello/yii2-x-editable 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 marciocamello/yii2-x-editable 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
X-Editable widget for Yii2.
bootstrap x-editable symfony2 forms integration
A custom URL rule class for Yii 2 which allows to create translated URL rules
X-editable extension for Yii2
The Yii2 extension uses jQuery jquery.carousel-1.1.min.js and makes image carousel from php array of structure defined.
TYPO3 CMS extension to create gallery content element with preset crop ratios and pagination
统计信息
- 总下载量: 8.93k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 22
- 点击次数: 11
- 依赖项目数: 4
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2014-03-24