spiral-project / daybed

Form validation and data storage API
http://daybed.rtfd.org/
BSD 3-Clause "New" or "Revised" License
53 stars 8 forks source link

Add a to string format string for the model #190

Closed Natim closed 9 years ago

Natim commented 9 years ago

On an item list, it could be nice to have a way to define how we want to handle the format.

My proposal is to add a format field like so:

{
  "definition": {
    "title": "Mobile Originated Numbers",
    "description": "Associate a country code to a number",
    "format": "%(mcc)s - %(moVerifier)s",
    "fields": [
      {
        "name": "mcc",
        "label": "Mobile Country Code",
        "type": "regex",
        "regex": "^[0-9]{3}$"
      },
      {
        "name": "moVerifier",
        "label": "MO Verifier Number",
        "type": "string"
      }
    ]
  }
}
leplatrem commented 9 years ago

I don't get it :(

What do you mean by "handle the format" ?

Natim commented 9 years ago

When you want to display a list of records I would like to be able to define the verbose name of a record

leplatrem commented 9 years ago

Ok, get it. Do you think it should belong to the official API ?

Since you can store whatever you like in the model definition, it does not have to be officially supported... And it won't be used on the server side if I'm not mistaken

Natim commented 9 years ago

Yes you are right but we should document it for people that will use daybed-admin. Le 9 août 2014 09:54, "Mathieu Leplatre" notifications@github.com a écrit :

Ok, get it. Do you think it should belong to the official API ?

Since you can store whatever you like in the model definition, it does not have to be officially supported... And it won't be used on the server side if I'm not mistaken

— Reply to this email directly or view it on GitHub https://github.com/spiral-project/daybed/issues/190#issuecomment-51680297 .

leplatrem commented 9 years ago

Well, I guess this could be managed on daybed admin directly (pick columns to be shown ?).

In the backbone-daybed CRUD demo, I used to show records in a table with columns http://spiral-project.github.io/backbone-daybed/#demo-poll-conf