Custom Field Template
[resolved] jQuery callback hooks - for child relationships (5 posts)

  1. scottconnerly
    Posted 4 years ago #

    I'm in the process of trying to make the select values a dynamic list of a different post type. For example, if I had a post type of states and another post type of cities. In my CFT for the cities, I'm looking to use AJAX to dynamically populate the states drop down.It seems to me that the best answer would be to allow for a jQuery callback in the document.ready() function in load_custom_field and allow me to extend it from there.

    Thanks for your consideration of this enhancement request


  2. scottconnerly
    Posted 4 years ago #

    Never mind. Used the 'PHP CODE' section. Would have appreciated more documentation on that area...

  3. llaughy
    Posted 4 years ago #

    Yes - I have been looking through the Options section and it would appear that there are any number of things that can be done with this plugin, but the README.txt file only seems to hint what they are for, with very little clue as to how to implement them.

    Can you give me a few hints on using the PHP Code section? The most basic question is does the PHP code added only affect how the form is constructed (as in your example)? In other words, if i want to add some PHP code that is conditional on the existence of data in the field (if data then print xyz following data)is this the way to do it? I am assuming you use code = 0 (or 1 etc.) to call the code?

    Thanks very much for any insight you can offer!

  4. scottconnerly
    Posted 4 years ago #

    For a template content of:

    type = select
    label = Office

    the block of code "Code #0" will be called. The $values and $valueLabel arrays are exposed at that time, so you can dynamically fill them. I ran a database query for my custom post type in my code block and set the values at that time. $values and $valueLabel are parallel arrays, and $valueLabel is not required if you want your items to have the same labels as their values.

  5. llaughy
    Posted 4 years ago #

    Thanks very much Scott - I will play around and see what I can make work. I appreciate the insight!

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Custom Field Template
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic