ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Cannot get Safecracker to work with Matrix

January 31, 2012 12:35pm

Subscribe [2]
  • #1 / Jan 31, 2012 12:35pm

    stevealfa

    11 posts

    I’m creating a form that auto populates some of it’s info from an existing channel and posts this info into another channel using safecracker.

    All works well except the matrix part, I can’t seem to find anything that will help me solve this, so I turn to you.

    this is what I am currently working on:

    {exp:channel:entries channel="seg1" limit="1" orderby="title" sort="asc" dynamic="off" disable="categories|pagination|trackbacks"}
    
    {exp:safecracker channel="orders" return="seg1/seg2/{url_title}#order" dynamic_title="[ordr_id]" id="inv_order_form"}
    
    ...all my other field here…
    
    <h3>Product Quantities</h3>
    <p><input type="hidden" name="ordr_prod_order[row_order][]" value="row_new_0"><br />
    {exp:channel:entries channel="products" dynamic="off" orderby="title" sort="asc" disable="categories|member_data|pagination|trackbacks"}<br />
    <div><br />
    {title}<br />
    <input type="text" name="ordr_prod_order[row_new_0][ordr_prod_nmszpk]" value="{title} {prdpksize1}x{prdsize1}" readonly /><br />
    <input type="text" name="ordr_prod_order[row_new_0][ordr_prod_qty]" value="" /><br />
    </div></p>
    
    <p>{/exp:channel:entries}<br />
    </div><!-- /order-products --></p>
    
    <p><input type="submit" value="Submit"><br />
    {/exp:safecracker}

    If I replace ‘ordr_prod_nmszpk’ with ‘col_id_1’ I get as many rows as products returned but they all just have the name of the last item in that list and the quantity col is always empty i’ve also tried ‘col_id_2’

    I can’t figure this one out or find a tutorial on this either.

    If somebody could help me solve this or point me in the right direction that would be much appriciated,

    Thanks.

  • #2 / Feb 01, 2012 5:56am

    Pv Ledoux

    95 posts

    Hi Steve,

    I think that row_new_0 must increment for each new row. Could you try:

    <input type="text" name="ordr_prod_order[row_new_{count}][ordr_prod_nmszpk]" value="{title} {prdpksize1}x{prdsize1}" readonly />
    <input type="text" name="ordr_prod_order[row_new_{count}][ordr_prod_qty]" value="" />

    Let me know if it’s working.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases