Home Forums Add-ons Repeater Field Change select values in a repeater


Change select values in a repeater

  • I have a “select” item in a repeater that loads a Cities Taxonomy.
    I wish to filter some of those value to only use the children of an specific parent.

    I’ve followed the instructions of this tutorial but it was in vain.

    I tried also with a query an populate the $field[‘ciudad’] with the value and the label but with some errors too.

    Here is the code I wrote:

    function my_acf_load_value( $value, $post_id, $field )
    		$field['ciudad'] = array();
    		global $wpdb;
    		$ciudades = '';
    		$sql = "	select, T.term_id
    					from 	wp_terms T
    							INNER JOIN wp_term_taxonomy TT ON T.term_id = TT.term_id
    					WHERE	TT.parent = 275";
    		$ciudades = $wpdb->get_results($sql);
    		foreach( $ciudades as $ciudad) {
    			array_push($field['ciudad'],array($ciudad->term_id => $ciudad->name));
    		return $field;
    	add_filter('acf/load_field/key=field_550028dcedab2', 'my_acf_load_value');

    Is there any other way to do it?
    Thanks in advance…

  • I could be wrong, but I don’t believe that the field keys of the ACF field array are translated, only their labels. So in the code where you have

    $field['ciudad'] = ...

    it should be

    $field['choices'] = ...;


    This can be verified by adding the following in your function:

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

The topic ‘Change select values in a repeater’ is closed to new replies.