Skip to content

Commit

Permalink
fix: template twig fixes, association views
Browse files Browse the repository at this point in the history
  • Loading branch information
arodu committed Mar 2, 2024
1 parent bc51495 commit b6f0c93
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 3 additions & 3 deletions templates/bake/Template/view.twig
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,15 @@ $this->Breadcrumbs->add([
{% endif %}
{% set relations = associations.BelongsToMany|merge(associations.HasMany) %}
{% for alias, details in relations %}
{% set otherSingularVar = alias|variable %}
{% set otherSingularVar = alias|singularize|variable %}
{% set otherPluralHumanName = alias|underscore|humanize %}
{% set otherSingularHumanName = alias|variable|underscore|humanize %}
{% set otherSingularHumanName = alias|singularize|underscore|humanize %}

<div class="related related-{{ otherSingularVar }} view card">
<div class="card-header d-flex">
<h3 class="card-title"><?= __('Related {{ otherPluralHumanName }}') ?></h3>
<div class="ml-auto">
<?= $this->Html->link(__('New {{ otherSingularHumanName }}'), ['controller' => '{{details.controller}}', 'action' => 'add'], ['class' => 'btn btn-primary btn-sm']) ?>
<?= $this->Html->link(__('New {{ otherSingularHumanName }}'), ['controller' => '{{details.controller}}', 'action' => 'add', '?' => ['{{ details.foreignKey }}' => {{ pK }}]], ['class' => 'btn btn-primary btn-sm']) ?>
<?= $this->Html->link(__('List {{ otherPluralHumanName }}'), ['controller' => '{{details.controller}}', 'action' => 'index'], ['class' => 'btn btn-primary btn-sm']) ?>
</div>
</div>
Expand Down
4 changes: 4 additions & 0 deletions templates/bake/element/form.twig
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ $this->Breadcrumbs->add([
?>

<div class="card card-primary card-outline">
{% if 'add' not in action %}
<?= $this->Form->create(${{ singularVar }}) ?>
{% else %}
<?= $this->Form->create(${{ singularVar }}, ['valueSources' => ['query', 'context']]) ?>
{% endif %}
<div class="card-body">
{% for field in fields %}
{%- if field not in primaryKey %}
Expand Down

0 comments on commit b6f0c93

Please sign in to comment.