[Dancer-users] Plugin::SimpleCRUD: primary key missing from edit form

WK wanradt at gmail.com
Thu Oct 20 15:29:18 CEST 2011


2011/10/20 WK <wanradt at gmail.com>:

> Why PK is missing from edit form?

I misunderstood a bit, i see now the id is get from posting URL, so
this is not the problem. Problem is: i have primary key not 'id' but
'ke_nr', if i change my table having pk as 'id' (and according option
for simple_crud), editing works fine.

I think the problem is here:

Line 462:
        if (exists params->{$key_column}) {

            # We're editing an existing record
            $success = database->quick_update($table_name,
                { $key_column => params->{$key_column} }, \%params);
            $verb = 'update';
        } else {
            $success = database->quick_insert($table_name, \%params);
            $verb = 'create new';
        }

It should begin:
        if (exists params->{id}) {

And then something like:

        $params{$key_column} = $params{id};
        delete $params{id};

Maybe it is cleaner to make attribution to right hash key somewhere
earlier, then if-block may remain same.

-- 
Wbr,
Kõike hääd,

Gunnar


More information about the Dancer-users mailing list