form.ctp
3.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<%
/**
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @since 0.1.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
use Cake\Utility\Inflector;
$fields = collection($fields)
->filter(function($field) use ($schema) {
return $schema->columnType($field) !== 'binary';
});
if (isset($modelObject) && $modelObject->behaviors()->has('Tree')) {
$fields = $fields->reject(function ($field) {
return $field === 'lft' || $field === 'rght';
});
}
%>
<nav class="large-3 medium-4 columns" id="actions-sidebar">
<ul class="side-nav">
<li class="heading"><?= __('Actions') ?></li>
<% if (strpos($action, 'add') === false): %>
<li><?= $this->Form->postLink(
__('Delete'),
['action' => 'delete', $<%= $singularVar %>-><%= $primaryKey[0] %>],
['confirm' => __('Are you sure you want to delete # {0}?', $<%= $singularVar %>-><%= $primaryKey[0] %>)]
)
?></li>
<% endif; %>
<li><?= $this->Html->link(__('List <%= $pluralHumanName %>'), ['action' => 'index']) ?></li>
<%
$done = [];
foreach ($associations as $type => $data) {
foreach ($data as $alias => $details) {
if ($details['controller'] !== $this->name && !in_array($details['controller'], $done)) {
%>
<li><?= $this->Html->link(__('List <%= $this->_pluralHumanName($alias) %>'), ['controller' => '<%= $details['controller'] %>', 'action' => 'index']) ?></li>
<li><?= $this->Html->link(__('New <%= $this->_singularHumanName($alias) %>'), ['controller' => '<%= $details['controller'] %>', 'action' => 'add']) ?></li>
<%
$done[] = $details['controller'];
}
}
}
%>
</ul>
</nav>
<div class="<%= $pluralVar %> form large-9 medium-8 columns content">
<?= $this->Form->create($<%= $singularVar %>) ?>
<fieldset>
<legend><?= __('<%= Inflector::humanize($action) %> <%= $singularHumanName %>') ?></legend>
<?php
<%
foreach ($fields as $field) {
if (in_array($field, $primaryKey)) {
continue;
}
if (isset($keyFields[$field])) {
$fieldData = $schema->column($field);
if (!empty($fieldData['null'])) {
%>
echo $this->Form->input('<%= $field %>', ['options' => $<%= $keyFields[$field] %>, 'empty' => true]);
<%
} else {
%>
echo $this->Form->input('<%= $field %>', ['options' => $<%= $keyFields[$field] %>]);
<%
}
continue;
}
if (!in_array($field, ['created', 'modified', 'updated'])) {
$fieldData = $schema->column($field);
if (in_array($fieldData['type'], ['date', 'datetime', 'time']) && (!empty($fieldData['null']))) {
%>
echo $this->Form->input('<%= $field %>', ['empty' => true]);
<%
} else {
%>
echo $this->Form->input('<%= $field %>');
<%
}
}
}
if (!empty($associations['BelongsToMany'])) {
foreach ($associations['BelongsToMany'] as $assocName => $assocData) {
%>
echo $this->Form->input('<%= $assocData['property'] %>._ids', ['options' => $<%= $assocData['variable'] %>]);
<%
}
}
%>
?>
</fieldset>
<?= $this->Form->button(__('Submit')) ?>
<?= $this->Form->end() ?>
</div>