本文整理汇总了PHP中Fields::hidden方法的典型用法代码示例。如果您正苦于以下问题:PHP Fields::hidden方法的具体用法?PHP Fields::hidden怎么用?PHP Fields::hidden使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fields
的用法示例。
在下文中一共展示了Fields::hidden方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
private function create($id = null)
{
$pdo = DatabaseFactory::getFactory()->getConnection();
$sql = "SHOW FULL COLUMNS FROM " . $this->table;
$fields = $pdo->prepare($sql);
$fields->execute();
$results = $fields->fetchAll();
//check to get the fields we want form our $selectcolumns, if needed
if (count($this->fields) < 0) {
//need to mlogic here, so its disabled (allow/disallow editing based on auth
foreach ($results as $values) {
if (in_array($values->Field, $this->fields)) {
$columns[] = $values;
}
}
} else {
//or else just get all of them..
$columns = $results;
}
//if we're given a key-value, then we are looking for a specific row.
// Get the values of the row and insert them
$data = null;
//initialize
if (isset($id)) {
//if we're not given specific fields, then we're getting every field
$pdo = DatabaseFactory::getFactory()->getConnection();
$sql = "SELECT * FROM " . $this->table . " WHERE id = " . $id;
$query = $pdo->prepare($sql);
$query->execute();
$data = $query->fetchObject();
}
$title = ucwords(str_replace('_', ' ', $this->table));
//splits table name, replaces the underscore (naming convention) and caps the first letter of each resulting word
$t = '
<div class="col-lg-5" />
<h3>' . $title . '</h3>
<form id="crud_' . $this->table . '_form" class="crudform " method="post" action="?action=update">
<input type="hidden" name="table" value="' . $this->table . '" readonly />';
foreach ($columns as $col) {
$colname = $col->Field;
$value = null;
// this should set the field values and choose the fields
if (!empty($data)) {
$value = $data->{$colname};
}
if ($col->Key == 'PRI') {
$t .= Fields::hidden($colname, $value, $colname);
} else {
if (isset($this->select) && $colname == $this->select) {
$list = array();
$options = FormModel::getrecord($this->optiontable);
foreach ($options as $k => $v) {
$list[$v->id] = $v->name;
}
$t .= Fields::select($colname, null, $list, $value);
} else {
if ($colname == 'user_editor') {
$t .= Fields::hidden('user_editor', Session::get('user_id'));
} else {
if (strpos($colname, '_ID')) {
$tbl = str_replace('_ID', '', $colname);
$tbl = str_replace('FK', '', $tbl);
$tbl = lcfirst($tbl);
$t .= Fields::selectgen($colname, $col->Comment, $tbl, true, $value);
} else {
$type = $col->Type;
switch ($type) {
case strpos($type, 'int'):
case strpos($type, 'smallint'):
case strpos($type, 'bigint'):
$t .= Fields::number($colname, $value, ucfirst($colname), $col->Comment);
break;
case strpos($type, 'tinyint'):
$t .= Fields::bool('active', $col->Comment, 'Active', 'Inactive', $value);
break;
case strpos($type, 'char'):
case strpos($type, 'varchar'):
case strpos($type, 'tinytext'):
case strpos($type, 'text'):
$t .= Fields::text($colname, $value, ucfirst($colname), $col->Comment);
break;
case strpos($type, 'longtext'):
case strpos($type, 'mediumtext'):
$t .= Fields::textarea($colname, $value, ucfirst($colname), $col->Comment);
break;
case 'date':
$t .= Fields::date($colname, $value, ucfirst($colname), $col->Comment);
break;
case strpos($type, 'timestamp'):
if ($colname == 'updated') {
$t .= Fields::hidden($colname, date('Y-m-d H:i:s'));
} else {
$t .= '';
//do not edit time stamp
}
break;
case strpos($type, 'time'):
$t .= Fields::date($colname, $value, ucfirst($colname), ucfirst($colname));
case strpos($type, 'datetime'):
$t .= Fields::date($colname, $value, ucfirst($colname), ucfirst($colname));
//.........这里部分代码省略.........
示例2: makeform
private function makeform($id)
{
$results = [];
foreach (get_object_vars($this->activeclass) as $key) {
$results[] = $key;
}
$pdo = DatabaseFactory::getFactory()->getConnection();
$sql = "SHOW FULL COLUMNS FROM " . $this->table;
$fields = $pdo->prepare($sql);
$fields->execute();
//$results = $fields->fetchAll();
//check to get the fields we want form our $selectcolumns, if needed
if (count($this->fields) < 0) {
//need to logic here, so its disabled (allow/disallow editing based on auth
foreach ($results as $values) {
if (in_array($values->name, $this->fields)) {
$columns[] = $values;
}
}
} else {
//or else just get all of them..
$columns = $results;
}
$data = null;
//initialize
if (isset($id)) {
//if we're not given specific fields, then we're getting every field
$pdo = DatabaseFactory::getFactory()->getConnection();
$sql = "SELECT * FROM " . $this->table . " WHERE id = " . $id;
$query = $pdo->prepare($sql);
$query->execute();
$data = $query->fetchObject();
}
$title = ucwords(str_replace('_', ' ', $this->table));
//splits table name, replaces the underscore (naming convention) and caps the first letter of each resulting word
//form layouts:
$cl = count($columns);
$colswanted = $cl < 12 ? 2 : 3;
$colslegth = $cl / $colswanted;
$t = '
<h3>' . $title . '</h3>
<hr/>
<div class="row">
<form id="crud_' . $this->table . '_form" class="crudform " method="post" action="?action=update&table=' . $this->table . '">
<input type="hidden" name="table" value="' . $this->table . '" readonly />
<div class="col-md-4" >';
$count = 0;
//counter for the form columns
foreach ($columns as $col) {
//$colname = $col->Field;
$colname = $col->name;
$value = null;
// this should set the field values and choose the fields
if (!empty($data)) {
$value = $data->{$colname};
}
//begin printing fields
if ($col->name == 'id') {
$t .= Fields::hidden($colname, $value, $colname);
} else {
if (isset($this->select) && $colname == $this->select) {
$list = array();
$options = FormModel::getrecord($this->optiontable);
foreach ($options as $k => $v) {
$list[$v->id] = $v->name;
}
$t .= Fields::select($colname, null, $list, $value);
} else {
if ($colname == 'editor' || $colname == 'created' || $colname == 'updated') {
$t .= '';
} else {
if (strpos($colname, '_type')) {
$t .= Fields::selectgen($colname, $col->label, $colname, true, $value);
} else {
if (strpos($colname, 'users')) {
$t .= '';
} else {
if (strpos($colname, '_id')) {
$tbl = str_replace('_id', '', $colname);
$tbl = lcfirst($tbl);
$t .= Fields::selectgen($colname, $col->label, $tbl, true, $value);
} else {
$type = $col->type;
switch ($type) {
case strpos($type, 'int'):
case strpos($type, 'smallint'):
case strpos($type, 'bigint'):
$t .= Fields::number($colname, $value, ucfirst($colname), $col->label);
break;
case strpos($type, 'tinyint'):
$t .= Fields::bool('active', $col->label, 'Active', 'Inactive', $value);
break;
case strpos($type, 'char'):
case strpos($type, 'varchar'):
case strpos($type, 'tinytext'):
case strpos($type, 'text'):
$t .= Fields::text($colname, $value, ucfirst($colname), $col->label);
break;
//.........这里部分代码省略.........