0

I have a Product channel for eCommerce that members can add entries to for sale on the website.

When a member creates the product, I want the Channel Form to set the value of the "Product Member" relationship field equal to the member who created it.

I am imagining a syntax similar to how I set the URL Title of a Channel Form entry.

<input type="hidden" name="product_member" value="{visitor:global:url_title}" />

Does anyone have any suggestions?

EDIT I found a solution before the answer posted. But Blatant's troubleshooting steps are correct nevertheless. After outputting the field using {field:product_farmer}, I was able to construct my hidden field to publish the new entry with the currently logged in user.

The end result is this syntax:

I noticed that relationship fields, whether they are one-to-many or many-to-many, use the same syntax (i.e. input type="hidden" name="custom_field_name[data][]" value="{entry_id}"). Zoo Visitor ID returns the channel entry ID of the currently logged in member.

1 Answer 1

1

First things first I would show the relationship field in the channel form using the fields variable syntax, this way you can see the source of the control and the value it would be posting.

I expect you'll see a select list with your members in it, and the values will be the member ID.

If this is the case, then you would be able to trick the form with a hidden input like this :

<input type="hidden" name="product_member" value="{member_id}" />

Note that this is not exactly 'safe' as anyone fwith Firebug for instance could swap the value out! The safer way would be to post process this in some way, most reasonable seems to be to use the channel-form-submit-entry-start event and incert the logged in Member ID.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.