本文整理汇总了PHP中DataTables\Editor::action方法的典型用法代码示例。如果您正苦于以下问题:PHP Editor::action方法的具体用法?PHP Editor::action怎么用?PHP Editor::action使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataTables\Editor
的用法示例。
在下文中一共展示了Editor::action方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: json_encode
<?php
/*
* Example PHP implementation used for the index.html example
*/
// DataTables PHP library
include "../../php/DataTables.php";
// Alias Editor classes so they are easy to use
use DataTables\Editor, DataTables\Editor\Field, DataTables\Editor\Format, DataTables\Editor\Mjoin, DataTables\Editor\Upload, DataTables\Editor\Validate;
// Build our Editor instance and process the data coming from _POST
$out = Editor::inst($db, 'datatables_demo')->fields(Field::inst('id')->set(false), Field::inst('first_name')->validator('Validate::notEmpty'), Field::inst('last_name')->validator('Validate::notEmpty'), Field::inst('position'), Field::inst('email'), Field::inst('office'), Field::inst('extn')->validator('Validate::numeric'), Field::inst('age')->validator('Validate::numeric'), Field::inst('salary')->validator('Validate::numeric'), Field::inst('start_date')->validator('Validate::dateFormat', array("format" => Format::DATE_ISO_8601, "message" => "Please enter a date in the format yyyy-mm-dd"))->getFormatter('Format::date_sql_to_format', Format::DATE_ISO_8601)->setFormatter('Format::date_format_to_sql', Format::DATE_ISO_8601))->process($_POST)->data();
// On 'read' remove the DT_RowId property so we can see fully how the `idSrc`
// option works on the client-side.
if (Editor::action($_POST) === Editor::ACTION_READ) {
for ($i = 0, $ien = count($out['data']); $i < $ien; $i++) {
unset($out['data'][$i]['DT_RowId']);
}
}
// Send it back to the client
echo json_encode($out);