jonseg / crud-admin-generator

An open source tool to generate a complete backend from a MySql database.
http://crud-admin-generator.com/
MIT License
1.43k stars 441 forks source link

Change column name #99

Closed hoangtrongphuc closed 8 years ago

hoangtrongphuc commented 8 years ago

How to change column' name in table ?

CecileV commented 8 years ago

Add a variable $table_columns_name in the $app->match('/access_logins', function () use ($app) in file /web/controllers/MODULE/index.php

This variable need to be an array with all field display in your list page.

Exemple :

    $table_columns = array(
        'id', 
        'type_id', 
        'name', 
        'description', 
        'created_at', 
        'modified_at', 
    );

    $table_columns_name = array(
        'N°', 
        'Project', 
        'Type', 
        'Name', 
        'Description', 
        'Created at', 
        'Modified at', 
    );

Add "table_columns_name" => $table_columns_name, in the return array.

Exemple :

    return $app['twig']->render('MODULE/list.html.twig', array(
        "table_columns" => $table_columns,
        "table_columns_name" => $table_columns_name,
        "primary_key" => $primary_key
    ));

In /web/view/MODULE/list.html.twig Replace :

                                    <thead>
                                        <tr>
                                            {% for table_column in table_columns %}
                                            <th>{{ table_column }}</th>
                                            {% endfor %}
                                            <th>Actions</th>
                                        </tr>
                                    </thead>

By :

                                    <thead>
                                        <tr>
                                            {% for table_column in table_columns_name %}
                                            <th>{{ table_column }}</th>
                                            {% endfor %}
                                            <th>Actions</th>
                                        </tr>
                                    </thead>

Sorry for my english. Bye !