+ = $this->Text->autoParagraph(h(${{ singularVar }}->{{ field }})); ?> ++
= $this->Flash->render() ?>
= $this->fetch('content') ?>
diff --git a/templates/plugin/Bake/Template/edit.twig b/templates/plugin/Bake/Template/edit.twig
new file mode 100644
index 0000000..90fed4e
--- /dev/null
+++ b/templates/plugin/Bake/Template/edit.twig
@@ -0,0 +1,35 @@
+{#
+/**
+ * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
+ * Copyright (c) Cake Software Foundation, Inc. (https://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. (https://cakefoundation.org)
+ * @link https://cakephp.org CakePHP(tm) Project
+ * @since 2.0.0
+ * @license https://www.opensource.org/licenses/mit-license.php MIT License
+ */
+#}
+
+{{ element('Bake.form') }}
\ No newline at end of file
diff --git a/templates/plugin/Bake/Template/index.twig b/templates/plugin/Bake/Template/index.twig
index 2006b95..55ffedb 100644
--- a/templates/plugin/Bake/Template/index.twig
+++ b/templates/plugin/Bake/Template/index.twig
@@ -23,11 +23,7 @@
{% set fields = Bake.filterFields(fields, schema, modelObject, indexColumns, ['binary', 'text']) %}
{% set done = [] %}
= __('{{ pluralHumanName }}') ?>
- = $this->Html->link( - __('New {{ singularHumanName }}'), - ['action' => 'add'], - ['class' => 'bg-red-700 hover:bg-red-900 text-white font-bold py-2 px-4 rounded'] - ) ?> + = $this->Html->link( __('New {{ singularHumanName }}'), ['action' => 'add']) ?>
@@ -42,7 +38,7 @@
-
+
{% for field in fields %}
{% set isKey = false %}
{% if associations.BelongsTo is defined %}
diff --git a/templates/plugin/Bake/Template/view.twig b/templates/plugin/Bake/Template/view.twig
new file mode 100644
index 0000000..ccd34b3
--- /dev/null
+++ b/templates/plugin/Bake/Template/view.twig
@@ -0,0 +1,158 @@
+{#
+/**
+ * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
+ * Copyright (c) Cake Software Foundation, Inc. (https://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. (https://cakefoundation.org)
+ * @link https://cakephp.org CakePHP(tm) Project
+ * @since 2.0.0
+ * @license https://www.opensource.org/licenses/mit-license.php MIT License
+ */
+#}
+
+{% set associations = {'BelongsTo': [], 'HasOne': [], 'HasMany': [], 'BelongsToMany': []}|merge(associations) %}
+{% set fieldsData = Bake.getViewFieldsData(fields, schema, associations) %}
+{% set associationFields = fieldsData.associationFields %}
+{% set groupedFields = fieldsData.groupedFields %}
+{% set pK = '$' ~ singularVar ~ '->' ~ primaryKey[0] %}
+
+
+
\ No newline at end of file
diff --git a/templates/plugin/Bake/element/form.twig b/templates/plugin/Bake/element/form.twig
index 8f0c46b..cfbca2c 100644
--- a/templates/plugin/Bake/element/form.twig
+++ b/templates/plugin/Bake/element/form.twig
@@ -15,20 +15,18 @@
#}
{% set fields = Bake.filterFields(fields, schema, modelObject) %}
+
+
+
+{% if groupedFields['string'] %}
+{% for field in groupedFields['string'] %}
+{% if associationFields[field] is defined %}
+{% set details = associationFields[field] %}
+
+{% if groupedFields.text %}
+{% for field in groupedFields.text %}
+
+ = h(${{ singularVar }}->{{ displayField }}) ?>
+= __('{{ details.property|humanize }}') ?> | += ${{ singularVar }}->hasValue('{{ details.property }}') ? $this->Html->link(${{ singularVar }}->{{ details.property }}->{{ details.displayField }}, ['controller' => '{{ details.controller }}', 'action' => 'view', ${{ singularVar }}->{{ details.property }}->{{ details.primaryKey[0] }}]) : '' ?> | +|
---|---|---|
= __('{{ field|humanize }}') ?> | += h(${{ singularVar }}->{{ field }}) ?> | +|
= __('{{ alias|underscore|singularize|humanize }}') ?> | += ${{ singularVar }}->hasValue('{{ details.property }}') ? $this->Html->link(${{ singularVar }}->{{ details.property }}->{{ details.displayField }}, ['controller' => '{{ details.controller }}', 'action' => 'view', ${{ singularVar }}->{{ details.property }}->{{ details.primaryKey[0] }}]) : '' ?> | +|
= __('{{ field|humanize }}') ?> | +{% set columnData = Bake.columnData(field, schema) %} +{% if columnData.null %} += ${{ singularVar }}->{{ field }} === null ? '' : $this->Number->format(${{ singularVar }}->{{ field }}) ?> | +{% else %} += $this->Number->format(${{ singularVar }}->{{ field }}) ?> | +{% endif %} +
= __('{{ field|humanize }}') ?> | +{% set columnData = Bake.columnData(field, schema) %} +{% set supportsLabel = Bake.enumSupportsLabel(field, schema) %} +{% if columnData.null %} += ${{ singularVar }}->{{ field }} === null ? '' : h(${{ singularVar }}->{{ field }}->{% if supportsLabel %}label(){% else %}value{% endif %}) ?> | +{% else %} += h(${{ singularVar }}->{{ field }}->{% if supportsLabel %}label(){% else %}value{% endif %}) ?> | +{% endif %} +
= __('{{ field|humanize }}') ?> | += h(${{ singularVar }}->{{ field }}) ?> | +|
= __('{{ field|humanize }}') ?> | += ${{ singularVar }}->{{ field }} ? __('Yes') : __('No'); ?> | +
+ = __('{{ field|humanize }}') ?>
+
+{% endfor %}
+{% endif %}
+{% set relations = associations.BelongsToMany|merge(associations.HasMany) %}
+{% for alias, details in relations %}
+{% set otherSingularVar = alias|singularize|variable %}
+{% set otherPluralHumanName = details.controller|underscore|humanize %}
+
+
+
+
+
+{% endfor %}
+ = __('Related {{ otherPluralHumanName }}') ?>
+ {{ details.property }})) : ?> += __('{{ field|humanize }}') ?> | +{% endfor %} += __('Actions') ?> | +
---|---|
= h(${{ otherSingularVar }}->{{ field }}) ?> | +{% endfor %} +{% set otherPk = '$' ~ otherSingularVar ~ '->' ~ details.primaryKey[0] %} ++ = $this->Html->link(__('View'), ['controller' => '{{ details.controller }}', 'action' => 'view', {{ otherPk|raw }}]) ?> + = $this->Html->link(__('Edit'), ['controller' => '{{ details.controller }}', 'action' => 'edit', {{ otherPk|raw }}]) ?> + = $this->Form->postLink( + __('Delete'), + ['controller' => '{{ details.controller }}', 'action' => 'delete', {{ otherPk|raw }}], + [ + 'method' => 'delete', + 'confirm' => __('Are you sure you want to delete # {0}?', {{ otherPk|raw }}), + ] + ) ?> + | +
-