Support

Account

Forum Replies Created

  • Hi Elliot!

    If I var_dump($field['name']); it just spits out the field name from when I set up the field string 'elevation' (length=9). Not sure if I did something wrong.

    From the field itself the elevation field ID value is acf-field-field_51e5de8ec13b9_0_field_51e5e09bc13bb_0_field_51eeec9096476 and the adjacent Home selector field ID is acf-field-field_51e5de8ec13b9_0_field_51e5e09bc13bb_0_field_51ef0daeb0698 – Not sure if those help.

    On a side note, before I posted here, I tried messing with some custom fields. I ended up creating a new field just for my elevations, and selecting the post type when I set up the field.

    I started with the post_object field and modified it a little to closer fit my needs. The largest major modification was how the field choices were loaded. Using the conventions already built into the field class I was able to load the elevations grouped by their parent Home.

    Here is that code:

    
    $elevations = get_field('elevations_repeater', $p->ID);
    if ($elevations) {
    	foreach ($elevations as $el) {
    
    		$elName = $el['elevation_name'];
    
    		$field['choices'][ $title ][ $elName ] =  $elName;
    	}
    	
    }
    

    Then all I had to do was change how the value was saved to the database as just the elevation name, so for the time being I have a workaround, but ultimately I’d prefer the functionality I am talking about.

    Thanks!

    David

  • Ok, after reviewing: http://www.advancedcustomfields.com/resources/tutorials/querying-the-database-for-repeater-sub-field-values/ I see that the row number is built in to the naming convention. I am still feeling a little lost though. If you can easily provide a code example that would sure help a lot 🙂

    Thanks!

  • …I would write some code to pick out the row number for the $field[‘name’] and use this to match the loop index. This will get you the current row.

    Can you elaborate on this a little for me? I understand most everything up to this point.

    How do I find the row number while inside my function for the load_field on Field B?

    Thanks again!

    David

  • First let me say I am loving ACF. Totally awesome.

    Your response is great, and I can tell is pointing me in the right direction… I think I need to add some additional clarification though, because my need goes a little deeper. Hopefully I can clarify.

    So I have two custom post types. “House Models” and “Neighborhoods”.

    When I save a new House Model, I enter variations in a repeater field; the variations are called “Elevations”. The Elevations are not shared by different House Models.

    Then when I am editing a Neighborhood, it has a repeater field called “Lots”. Inside each Lot I add to the repeater, I need to select a House Model (Simply done with the post_object fiel and our “Field A”). Then I need to select which Elevation of the House Model was built on that Lot with a select field (Field B). Ideally Field B will be limited to ONLY the Elevations entered for the chosen Home Model in Field A.

    Where I feel stuck now, how do I populate Field B with the Elevations saved to the Home Model selected in Field A. The difficulty comes for me because of the multiple instances of Field A and Field B because they are inside a repeater themselves…

    Does that make it any clearer?

    I REALLY appreciate your help!!!

    – David Ray

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