Matrix Edit Leads to duplicate rows
Posted: 29 January 2011 05:59 AM   [ Ignore ]
Wallflower
Rank
Total Posts:  6
Joined  2011-01-07

Hi,

I have SC working great for publishing entries. I want to use it to edit entries as well. One of my fields is a Matrix field. I want users to have limited options for the matrix field, basically, just check boxes for one column and a text input for the other. They can only edit the check boxes.

This works great for publishing new entries, but when they edit an existing entry, matrix ends up keeping the old rows and adding new ones, instead of just changing the existing ones.

This is the code I’m using to edit the entry:

{matrix_field}
    
<dt>
    <
input type="hidden" name="reg_itinerary_matrix[row_order][]" value="row_new_{row_id}">
    <
input type="hidden" name="reg_itinerary_matrix[row_new_{row_id}][col_id_41]" value="{meeting}">
    <
label><input type="checkbox" {if attending=='y'}checked="checked"{/if} name="reg_itinerary_matrix[row_new_{row_id}][col_id_36]" value="{attending}" /><span>{meeting}</span></label>
    </
dt>
    
{/matrix_field} 

Any ideas?

PS, it’s also not working to embed the matrix tag pair in the SC form. I’m having to use an embedded template with a channel tag in it.

Profile
 
 
Posted: 29 January 2011 09:15 PM   [ Ignore ]   [ # 1 ]
Wallflower
Rank
Total Posts:  6
Joined  2011-01-07

Sorry, just looking my code over again. I realize now that row_new_{row_id} should be row_id_{row_id}. That makes sense smile

Sometimes it pays to take a break and come back!

Profile
 
 
Posted: 30 January 2011 02:32 AM   [ Ignore ]   [ # 2 ]
Absolute Heartthrob!
Avatar
RankRankRankRankRank
Total Posts:  10369
Joined  2008-09-29

Absolutely. Glad you got it sorted.

 Signature 
Profile
 
 
Posted: 01 February 2011 06:45 AM   [ Ignore ]   [ # 3 ]
Wallflower
Rank
Total Posts:  5
Joined  2011-02-01

I’ve follwed theese steps, but it doesn’t seem to work for me. My code looks like this:
PS: “bd_lineup” is my matrix field name

{bd_lineup}
<li class="matrix-row">
    <
input type="hidden" name="bd_lineup[row_order][]" value="row_id_{row_id}" />
    <
label>Componente <input type="text" name="bd_lineup[row_id_{row_id}][col_id_31]" class="input lineup" title="nome artista" value="{name}" /></label
    <
label>Strumento<input type="text" name="bd_lineup[row_id_{row_id}][col_id_32]" class="input lineup" title="strumento suonato" value="{instrument}" /></label>
</
li>
{/bd_lineup} 

Using this piece of code it doesn’t render anything, but if i use the

{field:bd_lineup} 

syntax it shows me the table with content to edit inside…
What Am i wrong?

Some useful data (maybe):
EE 2.1.3
Safecracker 1.0.3
Matrix 2.1.2
safecracker_head=“no”

Thanks in advance for the kind reply.

Profile
 
 
Posted: 01 February 2011 11:05 PM   [ Ignore ]   [ # 4 ]
Absolute Heartthrob!
Avatar
RankRankRankRankRank
Total Posts:  10369
Joined  2008-09-29

Are you passing an entry id or url title into the safecracker tag?

 Signature 
Profile
 
 
Posted: 02 February 2011 03:43 AM   [ Ignore ]   [ # 5 ]
Wallflower
Rank
Total Posts:  5
Joined  2011-02-01

Yes, all the others fields show up correctly in the form, even the matrix one if i use the {field:bd_lineup} syntax…

[ Edited: 02 February 2011 09:48 PM by dibeja ]
Profile
 
 
Posted: 05 February 2011 01:32 AM   [ Ignore ]   [ # 6 ]
Wallflower
Rank
Total Posts:  5
Joined  2011-02-01

Any news about this problem?... I simply cannot use the {filed:custom_field} syntax in my project so I’m stuck…

Profile
 
 
Posted: 05 February 2011 03:32 AM   [ Ignore ]   [ # 7 ]
Absolute Heartthrob!
Avatar
RankRankRankRankRank
Total Posts:  10369
Joined  2008-09-29

I’ll reply today. I’m working through a big backlog of posts and PMs this week. Apologies for the slowness. I WILL get help to you soon.

 Signature 
Profile
 
 
Posted: 12 February 2011 10:42 PM   [ Ignore ]   [ # 8 ]
Teen Scream
Avatar
RankRankRank
Total Posts:  3541
Joined  2009-05-29

A few questions for clarification: When you say it doesn’t work for you, what exactly is the problem? Duplicate rows? And when you use the {field:} syntax, (I realize that isn’t appropriate for your project) does it work?

Profile
 
 
Posted: 14 February 2011 07:40 PM   [ Ignore ]   [ # 9 ]
Wallflower
Rank
Total Posts:  5
Joined  2011-02-01

I’ll try to better explain my problem:
I’ve got a safecracker EDIT form in wich there are several fields, mixed input text, textarea, radios and a couple of matrix fields.
All works fine (I can see the previous stored values and then change them) until i use the standard syntax for the “simple fileds” {ES: <input type="text" name="{my_custom_field}”....) and the {field:my_custom_field} for the complex one (Matrix, s3simple uploader and so on.)

On the matrix field if i use the {my_custom_field}{/my_custom_field} syntax nothing is shown inside the tag pair. Whatever i put between those tags simply does’nt show up on the page.

I wish i was able to style myself those fields (i don’t want all the saef CSS & JS crap to pollute my pages) even if this will mean I need to write a lot oj JS code…

Thanks.

Profile
 
 
Posted: 14 February 2011 09:20 PM   [ Ignore ]   [ # 10 ]
Teen Scream
Avatar
RankRankRank
Total Posts:  3541
Joined  2009-05-29

If you use the {my_custom_field}{/my_custom_field} syntax on your matrix field within an ADD (not edit) form, there is no entry, and therefore there are no matrix rows, hence the tag pair will not output anything. I suggest either using conditionals or a separate form to ADD entries, where you manually print out the matrix fields yourself, without using a tag pair.

Profile
 
 
Posted: 15 February 2011 03:08 PM   [ Ignore ]   [ # 11 ]
Wallflower
Rank
Total Posts:  5
Joined  2011-02-01

Thank for your kind reply,
but, as i wrote in my previous post, I’m in an EDIT form (with entry_id or url_title_path specified).
All the other fields output simething, matrix don’t.
All i want to know is if this kind of functionality is “not possible by design” or if it is only a problem of mine.

Thank you un advance.

Profile