1

I'm trying to figure out how to update my playa fields (member_firstname, member_lastname, etc) when they're inside of a safecracker form. All of the non-playa fields update:

{exp:safecracker
limit="1"
channel="business"
return="myfig/dashboard/success" 
datepicker="no"
url_title="{segment_2}"
safecracker_head="no"
error_handling="inline"
use_live_url="no"
author_only="yes"
}
<!--Entry Id: {embed:entry_id} -->
<p>
<label for="member_business_name1">Business Name</label>
{title}
</p>
{exp:playa:children field="contact" status="not closed" limit="1" entry_id="{embed:entry_id}"}
<p>

<label for="member_firstname">Primary Contact First Name</label>
<input type="text" name="member_firstname" id="member_firstname" value="{if member_firstname}{member_firstname}{/if}"/>
</p>
<p>
<label for="member_lastname">Primary Contact Last Name</label>
<input type="text" name="member_lastname" id="member_lastname" value="{if member_lastname}{member_lastname}{/if}"/>
</p>

<p>
<label for="member_job_title">Primary Contact Title</label>
<input type="text" name="member_job_title" id="member_job_title" value="{if member_job_title}{member_job_title}{/if}"/>
</p>
{/exp:playa:children}

Pastie: http://pastie.org/6405829

Any thoughts?

1
  • I've fixed your formatting. We use markdown for formatting here - simply indent code with 4 spaces, or click the {} button to do it automatically. Mar 10, 2013 at 4:53

2 Answers 2

1

I'm afraid you'll need to build a custom add-on to do this, since you're trying to update more than one channel entry with a single Safecracker submission. (In a single submission you can only create/update a single channel entry's fields - so you could change the related entry that your main entry points to, but not the fields of that related entry itself).

I built Bankcracker to do this for adding new entries, but it currently doesn't handle edits to existing data. However, it might point you in the right direction for creating something yourself. (The key would be to use the safecracker_submit_entry_end extension hook).

2
  • James, maybe my best bet is to separate the forms? Playa fields in one and non-playa in the other?
    – Jon Nixon
    Mar 10, 2013 at 17:34
  • I guess so. If it produces an unpleasant user experience you could also hack it with JavaScript like this: chiefalchemist.com/… Mar 10, 2013 at 18:34
0

Jon, have you tried using {field:contact} in your Safecracker form?

2
  • Lisa, do you mean {field:member_firstname}, {field:member_lastname}, etc?
    – Jon Nixon
    Mar 10, 2013 at 17:34
  • yes, Jon - that is it, if those are your custom field short names.
    – Lisa
    Mar 12, 2013 at 16:42

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.