Chief Alchemist - Business Consulting For The 21st Century Via A Holistic & Intelligent Approach
Share RSS 2.0 feed for Sign up for the mailing list. Follow Chief Alchemist on Twitter. 'Like' the Chief Alchemist's page on Facebook. See what Chief Alchemist has been Q&A'ing on Quora. Chief Alchemist bookmarks & highlights on Follow the Chief Alchemist on Chief Alchemist channel on Chief Alchemist on Flickr. Mark 'Chief Alchemist' Simchock on LinkedIn. Free Initial Consultation. Email Chief Alchemist. Phone Chief Alchemist.
  • Mark ‘Chief Alchemist’ Simchock
  • 'Email me.Email => ca .at. ChiefAlchemist .dot. com
  • 'Phone me.Alchemy United => 732 997-0028
  • Free initial consultation.Free => Initial Consultation
  • Please be sure to subscribe to your communication channels of choice.
  • Click To Close => The small green (consultation), red (email) or blue (phone) icons in the top upper right.
Business Consulting For The 21st Century Via A Holistic & Intelligent Approach

EE, SafeCracker, Ajax and updating multiple channels / entries

FYI => The UX called for a clean Ajax based updated within an ExpressionEngine SafeCracker form. That was fairly straightforward (aside from a quirk in the EE docs.) What wasn’t so standard was having to update two (or more) EE channels / entries via a single form submit. And this is where the alchemist magic started to happen.

In the comments at the bottom of the page JT Thompson runs down a few examples on using Javascript to manipulate key form fields / values. What I did was use jQuery’s ajaxSuccess method and then do the necessary manipulation. That is, I changed the channel_id and then did a second submit. The other key thing to know is that ExpressionEngine / SafeCracker will ignore any fields that don’t apply to a given channel / submit. In other words, you can have fields on a form for two or more channels and not pull and errors. If the fields don’t apply to a channel update they simply get ignored.

In summary it went like this…Set up the SafeCracker form with fields for two different channel. Do the first submit. If / when there’s an ajaxSuccess change the channel_id to the second channel. Submit again. Ideally, there’s a second success*. Done.

* I haven’t yet tried to figure out what to do if the first update is a success and the second is not.

Will not be published. Required.
Please include http://