CS Form - Create Post with image

Hey Guys,

I love your new Cornerstone extension. I was playing around with Joshs guide to CS Forms, where he sets up a form to create posts. That’s what I need. The video doesn’t cover how to upload an image besides the title an the content to the newly created post.

I have a ACF post type with an image field.

How can I realize that?

I’ll add in a post create with featured image template eventually to our Max templates. In your case since you are using ACF your form will be slightly different. The overall action flow will be Post Create > File Upload > Post Meta Update / ACF Post Update. Make sure File Upload has Has Multiple turned off otherwise you will have to loop over the images.

In your ACF Post Update action you are going to utilize Action Response Dynamic Content. When you use the Post Create action, your response is the new posts ID. Since it is two parents away, the depth will be 0. Put together that is {{ form_action.response({"depth":"1"}) }} in Twig. You can use that in the Post ID field. The File Uploads response will be the ID of the created media item. Since your ACF action will be a direct child of that action you can use {{ form_action.response }} in the meta value field. My screenshot shows setting that up for a Featured image.

Let us know if that helps and have a great day.

Hi Charlie,
this works very well with the featured image (Post Meta Update) . I could not manage to do it with an ACF field. In the ACF Post Field Update Action, I cannot choose the field to update. It just says “Select a field”. The list is empty because at this time no ACF post is selected, I think.

How can I address the ACF field?

If you press “CTRL+ALT+B” it will let you place anything in pretty much every field. The Page you are editing most likely doesn’t have the same Post Fields if you are creating a Custom Post Type. Let us know if that helps.

Now it works. Thank you!

With “CTRL + ALT +B” I was able to put the field name in.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.