Code Monkey home page Code Monkey logo

Comments (2)

bigpresh avatar bigpresh commented on July 3, 2024

Is this still valid?

Testing the example app, which uses foreign_keys for the employer_id column, it displays the name as employer_id, and gives me the available employer records to select from.

from dancer-plugin-simplecrud.

joshrabinowitz avatar joshrabinowitz commented on July 3, 2024

I see what this is about. I've worked up a branch to illustrate this:

https://github.com/joshrabinowitz/SimpleCRUDTest/compare/foreign-key-labels-gh-75?expand=1

The issue is if you have interfaces like this:

simple_crud(
    record_title=>'thing',
    prefix=> '/things',
    db_table=>'things',
    foreign_keys => { category_id => { table=>'categories', key_column=>'id', label_column=>'name' }},
    labels => { category_id=>"Category" },
);
simple_crud(
    record_title=>'category',
    prefix=> '/categories',
    db_table=>'categories',
);

and you have two tables like this, but with no data:

create table things ( id int PRIMARY KEY AUTO_INCREMENT, name varchar(255), category_id int);
create table categories ( id int PRIMARY KEY AUTO_INCREMENT, name varchar(255) );

Then when you go the /things/add form, there will be two text boxes present, one for the "name' and one for the 'category' (instead of the radiobuttons to chose one of the categories - which here don't exist).

I guess the right thing is to give the user an error message that there are no 'category' records to refer the foreign_key to?

from dancer-plugin-simplecrud.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.