Skip to content

Correção do erro index.twig que gerava erro: warning: Undefined array key "details" . #124

@jranesio

Description

@jranesio

Segue código corrigido.

{#
/**

{{ pluralHumanName }}
<div class="pull-right"><?php echo $this->Html->link(__('New'), ['action' => 'add'], ['class'=>'btn btn-success btn-xs']) ?></div>

      <div class="box-tools">
        <form action="<?php echo $this->Url->build(); ?>" method="POST">
          <div class="input-group input-group-sm" style="width: 150px;">
            <input type="text" name="table_search" class="form-control pull-right" placeholder="<?php echo __('Search'); ?>">

            <div class="input-group-btn">
              <button type="submit" class="btn btn-default"><i class="fa fa-search"></i></button>
            </div>
          </div>
        </form>
      </div>
    </div>
    <!-- /.box-header -->
    <div class="box-body table-responsive no-padding">
      <table class="table table-hover">
        <thead>
          <tr>

{% for field in fields %}
Paginator->sort('{{ field }}') ?>
{% endfor %}






{% for field in fields %}
{% set isKey = false %}
{% if associations.BelongsTo %}
{% for alias, details in associations.BelongsTo|filter((details) => field == details.foreignKey) %}
{% set isKey = true %}
has('{{ details.property }}') ? $this-&gt;Html-&gt;link(${{ singularVar }}->{{ details.property }}->{{ details.displayField }}, ['controller' => '{{ details.controller }}', 'action' => 'view', ${{ singularVar }}->{{ details.property }}->{{ details.primaryKey[0] }}]) : '' ?>
{% endfor %}
{% endif %}
{% if isKey is not same as(true) %}
{% set columnData = Bake.columnData(field, schema) %}
{% if columnData.type not in ['integer', 'float', 'decimal', 'biginteger', 'smallinteger', 'tinyinteger'] %}
{{ field }}) ?>
{% else %}
Number->format(${{ singularVar }}->{{ field }}) ?>
{% endif %}
{% endif %}
{% endfor %}
{% set pk = '$' ~ singularVar ~ '->' ~ primaryKey[0] %}

Html->link(__('View'), ['action' => 'view', {{ pk|raw }}], ['class'=>'btn btn-info btn-xs']) ?>
Html->link(__('Edit'), ['action' => 'edit', {{ pk|raw }}], ['class'=>'btn btn-warning btn-xs']) ?>
Form->postLink(__('Delete'), ['action' => 'delete', {{ pk|raw }}], ['confirm' => __('Are you sure you want to delete # {0}?', {{ pk|raw }}), 'class'=>'btn btn-danger btn-xs']) ?>









Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions