3

In the control panel, is it possible to only show a field when editing a single particular entry using JS/jQuery?

It's a matrix field, in case this makes any difference.

Thanks

1 Answer 1

2

Yes. You could write jQuery script that you put in the Instructions field for that entry. You could check the URL in JavaScript/jQuery for the particular Entry ID you want to isolate, and then hide the corresponding field & label.

Updated: A Matrix field will still have an Instructions field in its Channel Fields definition, and that Instructions field can store HTML or script tags that will be processed when the page is rendered. You'll just need to View Source to see what the HTML is that contains the field, and hide it based on that HTML reference using jQuery.

4
  • It's a matrix field, in case this makes any difference.
    – Abs
    Feb 4, 2013 at 16:32
  • Thanks for your help. I can hide it using jquery when the page loads. Can you help with the conditional? I want element to show if the url has this bit "entry_id=161".
    – Abs
    Feb 4, 2013 at 17:04
  • 1
    You don't necessarily need to check the URL for the entry id. The publish form will have a hidden input named entry_id that you can use to build your jQuery. For example $('#publishForm').has('input[name="entry_id"][value="161"]')...etc., etc.
    – Alex Kendrick
    Feb 4, 2013 at 17:31
  • Thanks it's working. The page publishes all sorts of variables and one of them was ChannelFiles.entry_id which used in the IF statement, so this is what I have got:<script type="text/javascript"> $(document).ready( function(){ $("#hold_field_24").hide(); if (ChannelFiles.entry_id == "161") { $("#hold_field_24").show(); } }); </script> Thanks for your help with the original question
    – Abs
    Feb 4, 2013 at 17:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.