0

I'm having trouble getting Safecracker to create the rows on a Matrix field. I've managed to get this to work IF the field is a 'Text Input' field.

But when the field is a Playa field, it doesn't create the row.

My code is (I'm pulling the data from a channel:entries loop):

{!-- Create New Row --}
<input type="hidden" name="member_courses[row_order][]" value="row_new_{exp:mx_calc expression="{count}-1"}">

{!-- Course ID / Name --}
<input type="hidden" name="member_courses[row_new_{exp:mx_calc expression="{count}-1"}][col_id_20]" value="[{entry_id}] [{url_title}] {title}">

I found that if you add this:

<input type="hidden" name="member_courses[selections][]" value="{entry_id}">

It should work, but it doesn't.

How can I get Safecracker to create an entry, that creates rows in a Matrix (But also creates the relationship)

1

You need to set the Playa input name to this:

field_name[row_new_X][col_id_Y][selections][]

And the value should only be the entry ID.

So in your case I guess that would be:

<input type="hidden"
       name="member_courses[row_new_{exp:mx_calc expression="{count}-1"}][col_id_20][selections][]"
       value="{entry_id}">
| improve this answer | |
  • Fantastic! That worked. I just couldn't get my head around it. – Jason Mayo Aug 19 '13 at 14:01

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.