FrozenNode / Laravel-Administrator

An administrative interface package for Laravel
http://administrator.frozennode.com/
MIT License
1.94k stars 503 forks source link

Error with relationship field #1032

Closed gregoryloichot closed 8 years ago

gregoryloichot commented 8 years ago

Hi.

I have a model like this :

class FEuser extends TranslatableModel
{
    protected $table = 'feusers';

    public function title () {
        return $this->belongsTo('App\Title');
    }
}

This model works perfectly well (including title relationship). So I created an administrator config file feuser.php containing

return array(
    'title' => 'FEusers',
    'single' => 'feuser',
    'model' => 'App\FEuser',

    /**
     * The display columns
     */
    'columns' => array(
        'title' => array(
            'title' => 'Title',
            'relationship' => 'title',
            'select' => '(:table).name'
        )
    ),

    /**
     * The editable fields
     */
    'edit_fields' => array(
        'title' => array(
            'title' => 'Title',
            'relationship' => 'title'
        ),
    ),
);

In my admin panel, I see the "title" column with the connect values inside. But when I want to edit an entry, the following error occurs:

local.ERROR: InvalidArgumentException: An invalid option 'multiple_values' was searched for in the 'denomination' field in /vendor/frozennode/administrator/src/Frozennode/Administrator/Fields/Field.php:267
Stack trace:
#0 /vendor/frozennode/administrator/src/Frozennode/Administrator/Config/Model/Config.php(245): Frozennode\Administrator\Fields\Field->getOption('multiple_values')
#1 /vendor/frozennode/administrator/src/Frozennode/Administrator/Config/Model/Config.php(169): Frozennode\Administrator\Config\Model\Config->getModelRelatedItems(Object(App\FEuser), Object(Frozennode\Administrator\Fields\Text))
…

If a change the config like that:

'edit_fields' => array(
        'title' => array(
            'title' => 'Title',
            'type => 'text'
        ),
    ),

The edit mode works and display the correct title_id in the feusers table.

Could you help me?

gregoryloichot commented 8 years ago

Ok,

Sorry, I found the solution.

In fact, the documentation on your website is not up to date. But the documenation on github is correct:

'title' => array(
            'title' => 'Title',
            'type' => 'relationship',
            'field_name' => 'name'
        ),

is the correct configuration.