Support

Account

Home Forums General Issues how to disable non-text fields, like a checkbox field Reply To: how to disable non-text fields, like a checkbox field

  • OK, after more tests I realize I was wrong on multiple aspects :

    1. the ‘disabled’ attribute don’t do what I expected : if a field is marked as disabled, and you are on the post edit panel in admin for example, then when you update the post, the field will be updated by acf with empty values, that’s not what want. I want to not be able to modify the field from front, only seeing it.

    2. the field object that is updated with different filters is always the real object. That’s obvious actually, but I misunderstood that, so my previous approach could not work : we cant use the field object properties to know if the field is updated from front or not, because it will be the same properties, no matter where it is updated from.

    3. and I think it is not safe to add a property to the object anyway, because it could be cleaned by acf at any time, even if I don’t think it’s the case so far.

    So i’m back to my first solution, using $_POST[‘acf’] to check if the field is updated from client side or not, but I’m still not sure if it’s robust.

    there is this proposition to use debug_backtrace() but I haven’t tried it : https://stackoverflow.com/questions/42032848/how-create-read-only-afc-field