We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3496
    • 101 Posts
    I’m rather new in the PHP/Javascript/MODx world and I am trying the dbEdit module as described here - and it works nicely, but I have some questions I have some trouble finding answers on:

    1. How to handle image files.
    1a. How could I get dbEdit to give me the option of uploading an image-file for certain fields?
    1b. What will it do with the files - will it store them in the database? Or will it store them in files and store the filename in the database?
    (both is fine with me, but I’ll have to adjust the table definition accordingly of course).

    2. How to handle foreign keys.
    I use lot’s of foreign keys (all done using id’s) to different tables - and dbEdit now asks for the id to be filled in by hand, and I would like my users to work with more "real life data".
    Example: "catid" is the id of the "category" table. Now when the user is adding a new product, he (or she) should indicate the right category for the product - but I would like him to be able to pick the right category by name from a dropdownlistbox or something like that.
    Is it possible to do something like that (enter a "name" instead of "id" for references to other tables) with dbEdit?
    And if it’s not possible: could someone give me some pointers about where I should add my own code?

    Thanks in advance!
      • 30223
      • 1,010 Posts
      1. How to handle image files.
      1a. How could I get dbEdit to give me the option of uploading an image-file for certain fields?
      1b. What will it do with the files - will it store them in the database? Or will it store them in files and store the filename in the database?
      (both is fine with me, but I’ll have to adjust the table definition accordingly of course).

      1. Edit the configuration and set the ’format’ to "image" in the field properties. This will give you an insert image button so you can select an image using the modx image/file manager dialog.
      1a. You can upload a new image from the image/file dialog.
      1b. It will only save the path to the image file on the server.

      2. How to handle foreign keys.
      I use lot’s of foreign keys (all done using id’s) to different tables - and dbEdit now asks for the id to be filled in by hand, and I would like my users to work with more "real life data".
      Example: "catid" is the id of the "category" table. Now when the user is adding a new product, he (or she) should indicate the right category for the product - but I would like him to be able to pick the right category by name from a dropdownlistbox or something like that.
      Is it possible to do something like that (enter a "name" instead of "id" for references to other tables) with dbEdit?
      And if it’s not possible: could someone give me some pointers about where I should add my own code?

      This should work. Again in the ’format’ column of the field properties. Set the format to something like "select@SELECT name,id from category"

        • 30223
        • 1,010 Posts
        Quote from: Sylvaticus at Oct 15, 2009, 08:39 AM

        When using the dbEdit as a datagrid, the data is paginated above a given number of rows in the database. Doe’s some of you know where to "turn off" that pagination?

        The reason I ask is because the sorting script from my last post doesn’t work when the data in the datagrid, set up via the dbedit module, is paginated.

        If I remember correctly the number of records shown is determined by the "Number of Results" setting in the modx configuration (interface & features tab)...
          • 3496
          • 101 Posts
          @TobyL/Jelle: thanks for the quick response and the instructions!
          Quote from: TobyL at Oct 21, 2009, 11:03 AM

          1. How to handle image files.
          Edit the configuration and set the ’format’ to "image" in the field properties. This will give you an insert image button so you can select an image using the modx image/file manager dialog.
          If I do that and click on save I get the following error:
          Unable to save configuration. Reason is:

          Are there any requirements for the data type of the data column in which the filename should be stored? Or could there be a different reason for this error?
          2. How to handle foreign keys.
          This should work. Again in the ’format’ column of the field properties. Set the format to something like "select@SELECT name,id from category"
          That worked like a charm; thanks!
          And for other people trying the same: I now also included an advanced setting for "select_sql" with the right SELECT statement (SELECT catnaam, mnaam FROM categoriemerk INNER JOIN (categorie, merk) USING (catid, mid) {WHERE} {FILTER} ORDER BY catnaam ASC, mnaam ASC) to get the same meaningful values (not the id’s) in the list.
            • 30223
            • 1,010 Posts
            Quote from: Black at Oct 22, 2009, 05:42 AM

            Quote from: TobyL at Oct 21, 2009, 11:03 AM

            1. How to handle image files.
            Edit the configuration and set the ’format’ to "image" in the field properties. This will give you an insert image button so you can select an image using the modx image/file manager dialog.
            If I do that and click on save I get the following error:
            Unable to save configuration. Reason is:

            Are there any requirements for the data type of the data column in which the filename should be stored? Or could there be a different reason for this error?

            Obviously a numeric type wouldn’t work too well smiley Any text type should do though.
              • 3496
              • 101 Posts
              Quote from: TobyL at Oct 24, 2009, 08:44 AM

              1. How to handle image files.
              Edit the configuration and set the ’format’ to "image" in the field properties. This will give you an insert image button so you can select an image using the modx image/file manager dialog.
              Question:
              Are there any requirements for the data type of the data column in which the filename should be stored? Or could there be a different reason for this error?
              Answer:
              Obviously a numeric type wouldn’t work too well smiley Any text type should do though.
              Thanks; I had tried it with varchar, which didn’t work, but text works perfectly!
                • 25863
                • 1 Posts
                Hi,
                I have been having difficulty in using this module. I have downloaded the files and added contents to modules as it has been explained. And after i try to run this module "dbedit" i am provided with "Close dbedit" and "Add new table". As i click the add new table i am taken to a new page with few images missing. There is a label "Table Name" but there isn’t any list of table. I am quite confused how the module works. Can any one please help me on this issue?


                Ok got it. Please ignore it.
                  • 29076
                  • 615 Posts
                  Quote from: TobyL at Oct 21, 2009, 11:11 AM

                  Quote from: Sylvaticus at Oct 15, 2009, 08:39 AM

                  When using the dbEdit as a datagrid, the data is paginated above a given number of rows in the database. Doe’s some of you know where to "turn off" that pagination?

                  The reason I ask is because the sorting script from my last post doesn’t work when the data in the datagrid, set up via the dbedit module, is paginated.

                  If I remember correctly the number of records shown is determined by the "Number of Results" setting in the modx configuration (interface & features tab)...
                  Thank you very much, it work. laugh I didn’t know about that one.
                    I think, thererfor I am! But what I am, and why...?
                    • 3496
                    • 101 Posts
                    I notice something strange:
                    When I try to insert a couple of records in a table using the "After Saving Add another"-option, I get an error after the first Save: "0records were found" while the record (first record) is inserted succesfully.
                    But all records inserted after that (while still using After saving Add another) are not inserted in the database.
                    The table I’m using here is a very simple one: id-column (NotNull, AutoIncrement), name-column and an optional integer column that I have not filled in yet. So I’m only filling in names.
                      • 5340
                      • 1,624 Posts
                      EDIT: I managed to understand it. Thx


                      Hi

                      Where can I find some examples or documentation except readme.txt.

                      Here’s what I’ve done so far:

                      1. Created the table
                      2. I can see the table in dbedit

                      What I need
                      3. A way for a manager to update the table. All fields except id.
                      4. A way to show the table on frontend(I can do this with the modx api)

                      Thx