Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

how to disable column from editing in Adminer Editor?

Help
Ciki
2014-05-21
2014-11-04
  • Ciki
    Ciki
    2014-05-21

    I'd like to disable column from editing(including inline editing) in Adminer Editor but still display it for read-only access. How do I do that?

     
  • Paul
    Paul
    2014-06-01

    That sounds like a very, VERY customized need for what you would like to do.

    I do NOT forsee Adminer trying to implement anything to cover such a special need, but this is just my two cents.

    That could possibly be done, but it will NOT be a trivial task, and would need to be maintained in your own [modified] code, and the change(s) will have to be manually copied/merged into any future versions if you decide to upgrade.

    There are many things to consider: [and know that this is NOT an exhaustive list]

    1. What if the desired column appears in another table, and you do NOT want that field found in the other table to be read-only?
    2. What if the column name is altered/changed? Unless the change aligns to your customization, then the read-only notion will be lost.
    3. Will the read-only still be 'safe' from a potential external POST ?
    4. Depending upon how/where you implement the read-only, will it be safe from browser debugger modifications?
    5. Your customizations [previously mentioned] will need manual merging into new Adminer versions, which may or may not be easy, depending upon future Adminer changes.
    6. Etc ?

    All that being said, there might be one possible work around for that limitation, assuming the field is to be the SAME for all users, is to create a BEFORE UPDATE trigger [or AFTER UPDATE, depending on how you'd like to handle] to reset the field to the desired value if the new value is not equal to the old value. [I'm assuming MySQL here, AND you have a version that supports triggers]

    With the trigger, you won't have to worry about all the UI-side read only handling hassles either, as the field is reset/restored by the trigger during the update, and the trigger is table-specific. Of course, using a trigger assumes a user does NOT know/understand triggers, which might be editable to them depending on permissions, and if they do, then there is still a pitfall to changes this way, though usually not as obvious.

     
    Last edit: Paul 2014-06-02
  • Jakub Vrána
    Jakub Vrána
    2014-06-15

    The best way how to do this is by setting MySQL privileges. Adminer respects them.

    If you are not doing this for security purposes but just to hide this option in the UI, you can also use the editInput() method: http://www.adminer.org/en/extension/#api. Returning an empty string from fieldName() method in edit mode will also do the trick.

     
  • Ciki
    Ciki
    2014-08-27

    Hm I thought I get some kind of notification when there come new comments here..

    Anyway, all I want to do is to disable editing from UI point of view. I don't do this for security reasons. In particular, the UI interface consists of only translations table with msg_id column which should never be changed but should be still visible to the user so he can update translation strings (in other columns) accordingly. So it cannot be simply hidden. Is there a way to add html attribute such as disabled or readonly to the column/table-cell ?

    Or is there at least some function in Adminer called on before update (not the sql trigger alone) so I would prevent updating msg_id?

    Thank you very much both of you for your comments!

     
  • Jakub Vrána
    Jakub Vrána
    2014-09-13

    I would suggest hiding msg_id column altogether. Adminer will still work with it even if it's hidden and it shouldn't be interesting for the user.

     
  • Ciki
    Ciki
    2014-11-03

    As I originally stated the msg_id column is used for string identification so it cannot be hidden. The user is client/admin.

    the UI interface consists of only translations table with msg_id column which should never be changed but should be still visible to the user so he can update translation strings (in other columns) accordingly. So it cannot be simply hidden.

    Any other ideas?