Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

how to disable column from editing in Adminer Editor?

Help
Ciki
2014-05-21
2014-06-15
  • 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.