2

Here's my scenario: I've got 2 channels, accounts and leads. The leads channel has a playa field (single select) that relates to accounts. Then I have a safecracker form that allows users to create a new lead entry. Everything works fine.

However, the current workflow dictates that the account must already exist before a lead can be associated with it. The ideal solution would allow the user to either choose an existing account, or create a new one without leaving the page, and updating the playa field with the new account.

I managed to get halfway there by placing a link beside the playa field which fires a modal with another safecracker form for the account creation, and using ajax to refresh playa select field. After adding the account entry, the new entry shows up in the playa select field, but when I submit the lead form, the playa field isn't being saved to the entry.

Has anyone tackled a similar problem? I would love to hear your solution/s.

Thanks,

Fabian

  • 1
    if you're using jQuery to update the playa select, are you using the live (deprecated in 1.7) or the on method. Hope that helps! – Mike Hughes Jan 11 '13 at 21:14
  • Hi Mike, I'm not using either. I was trying to use load to replace the playa select field with a new select field from a template that has another safecracker lead form, but only returning the playa field. Which totally explains why it isn't working, and how much of a noob I am. Thanks for pointing me towards the on method. Reading up on it now! – Fabian Jan 11 '13 at 21:27
  • No problem... it may actually be difficult if your modal is loading an outside page. Perhaps you could have a div within your page that is hidden with the reg form, submit that via ajax and when you get a success return you could add the new user to the playa fields. – Mike Hughes Jan 11 '13 at 21:35
  • Hi Mike - try to avoid posting a follow up question as an "answer", comments are best suited for this. I've converted your post into a comment for now :) Once you have a full solution, post it as an answer and mark it as accepted. – Adrian Macneil Jan 11 '13 at 22:04
  • Is your Playa field being created using {field:field_name}, or are you manually creating a <select> element yourself? How exactly are you refreshing it? Can you post any relevant template/JS code? – Brandon Kelly Jan 12 '13 at 17:42
3

This may or may not be what you're looking for as I only really glanced at your question. I had a problem with playa fields in that I was using the wrong name on the select.

For example if your playa field name is lead_account, rather than declaring your select with the name: lead_account you specify it as lead_account[selections][]

Conor

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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