Support

Account

Home Forums Bug Reports disable via prepare_field

Solving

disable via prepare_field

    • jcarter

    • December 17, 2016 at 8:43 am

    Hi

    When adding a prepare_field filter that disables or makes a field readonly by adding $field['disabled'] = true; for certain field types doesn’t work.

    ‘user’ field: the select2 still renders.

    ‘true_false’ field: the field output is not changed where I was expecting "disabled"="disabled"

    Thanks

  • Not all select 2 fields can be disabled. Actually, I’m not sure that any select2 fields can be disabled.

    In the case of the true/false field it could be something in the code for the new UI for these fields. Are you seeing the problem with the stylized UI on or off?

  • One year passed and we still are here… I can’t use $field[‘disabled’] = true; for ‘true/false’-field, because that doesn’t work. It’s a bit strange to have the functional which don’t work with two type of field. Why that is?

    “Are you seeing the problem with the stylized UI on or off?” – Yes.
    If I make the field[‘ui’] = 0; then will $field[‘disabled’] = true work? Where I need do it? I mean now I work into ‘acf/prepare_field’.

  • The stylized UI uses a select2 field and not a checkbox field. Select2 fields cannot be disabled. It might be possible to do by adding custom JavaScript, but to be honest I don’t know for sure. But it can’t be done using the prepare field hook or in PHP using any hook.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.