Support

Account

Forum Replies Created

  • I dont know what happened but the thread is showing as solved. I must have done something by accident. Any way to un-solve this please?

  • I’m noticing that each time I reply, I have to re-check the notification icon at the top of this thread. It seems to turn off.

    Anyway, regards your code there. I can use it to fetch the contents of any field in a repeated. But not sure how I would apply it when trying to bring up a front end form for editing that field. Is it used along with acf_form or some other way?

  • Thanks James. Nice idea using static variables. Unfortunately, when using your example, $count is always 1. It seems to be getting reset to 0 even though its defined as static. As far as I can see it should work. Any clue as to why?

  • Yes. For example, say I have a repeater containing a text field, and on the edit page I add 5 repeater rows. I want to target the text fields and give them each a unique wrapper ID.

    Currently my code looks like this:-

    
    function my_acf_load_field( $field )
    {
        $field['wrapper'] = array(
            'id' => 'unique_id'
        );
    
        return $field;
    }
    	
    	add_filter('acf/load_field/key=field_123', 'my_acf_load_field');
    

    With field_123 being the text field. But this will give all 5 text fields the same ID: ‘unique_id’. What I would like is for each text field to have a sequential ID. for example “unique_id_1′, ‘unique_id_2’… etc.

    Any ideas?

  • I gave that a bash John, and I think I am almost there with it.

    One last this I would like to attempt is to sequentially name the IDs im defining using load_field.

    For example, if I have several repeater fields, to be able to define their wrapper IDs as “box1”, “box2”, “box3” etc. They all share the same field ID so im finding it difficult targeting each one specifically. Any ideas on how to pass this extra value via the filter?

    Thanks again. You’ve been a great help.

  • Thanks very much Elliot. Sorry I didn’t get back to you earlier. I thought I had subscribed to this thread but never got a notification.

    Your suggestion sounds like it has some potential. Ultimately, what I would like is to set some kind of variable/flag when rows have been added/rearranged. I could then use this with your above code to determine whether to save all fields regardless of c-logic, or to work normally if the flag is not set = no rows have been added/moved. Does this sound feasible?

  • Thanks John. Only just seen this. Never got an email notification for some reason.

    Anyway, you are right. As im using a repeater with a few wysiwyg editor fields, I am looping through the rows.

    Ok, so saying I have 5 or so repeater editors and im outside the row loop, how do I target a particular editor? They all share the same field key, so I only get the last one in my form.

    Thanks again John.:)

  • Thanks Elliot

    I’m using the latest ACF pro.

    Regards you above code snippet: Will that make it so all c-logic hidden fields will save on update, regardless if they are hidden or not?

    As for usage, where would I place the code? Im not sure exactly what you mean by the admin page.

    Also,I wanted to point out that im running WP on a local host using wamp. I should have probably told you this from the beginning in case it has a bearing. Sorry about that.

  • Thanks John.

    I’m using the latest version of pro.

    I was calling acf_form outside the loop as far as im aware. Its a strange one. If I call acf_form() with an empty array, it displays the the fields on the page with a the contents correctly. But when I try and pick out the wysiwyg specifically, the form displays the editor but its contents are empty.

    Having said that, there was an important bit of info I forgot to provide: Im running wordpress on a localhost using wamp. Does this have any bearing on how acf_form works?

  • Thanks for the tip John. I’ll investigate load_filter and see if I can get it to work.

  • Thanks for the suggestions Elliot.

    I do understand how c-logic works. After all, its the fact that it doest save hidden contents that makes it so useful on very busy pages as not only does it hide fields but also makes updates much faster because hidden fields dont save. But when considering repeaters/flexible fields and their great ability to re-arrange rows, the two are tricky to use together. Its not an easy thing to expect clients to un-hide all hidden fields before re-arranging rows as they will inevitably forget on occasion and ruin their content – which is exactly what happened to me. I only found the error because of my client. With this in mind, can you please consider a solution?

    I appreciate your idea regards collapse-able flexible layouts. In fact, my actual website is using flexible, not repeaters as in my example. But there are some problems with this method:-

    – when flexible layouts are collapsed, theres no way to name the remaining title-bar with anything but the layout name. So if I have 20 of the same layout, and they are all closed, its difficult finding the one that needs working on without opening them all as they all have the same label.
    – after updating a page, all the collapsed layouts are made open again. This can be frustrating if working on a single layout and having to close the others with every update.
    – I dont really want to hide *all* the contents of a layout. In my example, I set up a simple repeater for clarity, but the actual website has lots of fields inside each flexible layout and I need a few of them to remain visible. This lets me fiddle with some essential parameters without opening the whole layout. eg, It allows me to have a text field outside the c-logic that the client can use to name each repeater for easy reference.

    Only thing I can think to suggest is maybe setting a flag if any rows have been re-arranged or inserted. If this flag is set when the user updates a page, then save all fields on the page regardless of whether they are hidden by c-logic. Is this at all possible?

    Thanks very much for taking the time to discuss this with me Elliot. I appreciate it.

    Mike

  • To add to the above, I thought it might help to post up some images showing the problem. I decided to use a text field instead of a WYSIWYG editer, to keep the images compact and clear.

    To begin with, I create 5 rows, each containing a c-logic checkbox and a text field. The checkbox determines whether the text field is visible or not. I save/update the page and the result looks like this:-

    Initial setup

    I then uncheck the checkboxes to hide the text fields and update the page again:-

    Hide text fields

    Then, I insert a new row between rows 2 and 3 and populate the new text field with “new row” :-

    Insert new row

    Now, if I press update and then make all the rows visible, I get the following:-

    Borked rows

    As you can see, the rows and their data have not moved down as expected. Row 3 has been wiped and replaced with the new row.

    Thanks

  • Thanks for the input! 🙂

    I did notice that tucking some of the fields away under conditional logic certainly helped with the update time. Im guessing this is because fields currently hidden behind conditionals wont save any data when update is pressed.

    This leads me to believe its possible to streamline the update process. Basically, only fields that have been changed should be updated instead of each and every field. Would it not be possible to flag only the fields that have new data and only update those fields when update is pressed? Essentially treating any un-changed fields as if they we’re hidden by conditionals? I think this would speed up the update process, seeing as hiding all my fields ( except the one ive changed ) behind conditionals seems to speed up the update considerably.

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