1 of 2
1
EE2, Matrix, SAEF, and SafeCracker
Posted: 18 February 2011 08:36 AM   [ Ignore ]
Wallflower
Rank
Total Posts:  23
Joined  2010-06-10

I’m having trouble trying to figure out how to implement a Stand Alone Entry/Edit Form using Matrix and SafeCracker.

Help?

Profile
 
 
Posted: 18 February 2011 11:53 PM   [ Ignore ]   [ # 1 ]
Teen Scream
Avatar
RankRankRank
Total Posts:  3541
Joined  2009-05-29

Hi, there’s two ways to implement matrix: use the custom_fields loop, or not.

{exp:safecracker channel="your_channel" entry_id="{segment_3}"}

{custom_fields}
....
{if matrix}
    {display_field}
{
/if}
...
{/custom_fields} 


Or

{exp:safecracker channel="your_channel" entry_id="{segment_3}"}

{field
:your_matrix_field_name} 
Profile
 
 
Posted: 19 February 2011 12:17 AM   [ Ignore ]   [ # 2 ]
Wallflower
Rank
Total Posts:  23
Joined  2010-06-10

This is for an entry form as well as an edit form?

If so, I’m confused why there would be an entry_id in the url.

Profile
 
 
Posted: 19 February 2011 12:19 AM   [ Ignore ]   [ # 3 ]
Teen Scream
Avatar
RankRankRank
Total Posts:  3541
Joined  2009-05-29

It’s flexible, so if there’s an entry_id in segment_3, it will be an edit form. If there’s no entry_id in the url, it will be an entry form.

Profile
 
 
Posted: 19 February 2011 02:15 AM   [ Ignore ]   [ # 4 ]
Wallflower
Rank
Total Posts:  6
Joined  2011-02-19

I’m having sort of the same issue:

1. I have a Matrix fieldtype that holds a list of user photos, state, and city.
2. I want users to be able to update that matrix via form, by uploading their picture, and entering their state and city.
3. I have the matrix displaying ok, but how do I allow it to be updated (not edited)?
4. I’ve tried hardcoding specific form inputs, but can I include the file input fieldtype for this?
5. yes, I’m a noob:)

Profile
 
 
Posted: 19 February 2011 02:15 AM   [ Ignore ]   [ # 5 ]
Teen Scream
Avatar
RankRankRank
Total Posts:  3541
Joined  2009-05-29

What do you mean updated, but not edited?

Profile
 
 
Posted: 19 February 2011 02:17 AM   [ Ignore ]   [ # 6 ]
Wallflower
Rank
Total Posts:  6
Joined  2011-02-19

Users can’t edit any of the other rows in the matrix, just add a new row. My terminology might be off..

Profile
 
 
Posted: 19 February 2011 02:25 AM   [ Ignore ]   [ # 7 ]
Teen Scream
Avatar
RankRankRank
Total Posts:  3541
Joined  2009-05-29

I see…that’s not easily done. I guess you could add the readonly property to the existing matrix fields with JS on the page load, something like:

...
{/exp:safecracker}
script >
$(function()
{
    
$('#your_matrix_field_name :input').attr('readonly''readonly');
});
< /
script 
Profile
 
 
Posted: 19 February 2011 02:31 AM   [ Ignore ]   [ # 8 ]
Wallflower
Rank
Total Posts:  6
Joined  2011-02-19
Rob Sanchez - 19 February 2011 02:25 AM

I see…that’s not easily done.

hmm, ok. So just to clarify, its not possible to show just the form to insert a new row into a matrix?

Also, I’m getting this JS error when displaying my matrix in the page:

TypeErrorResult of expression '$.ee_filebrowser' [undefined] is not a function. 

Thanks for you help!

Profile
 
 
Posted: 19 February 2011 02:35 AM   [ Ignore ]   [ # 9 ]
Teen Scream
Avatar
RankRankRank
Total Posts:  3541
Joined  2009-05-29
garth - 19 February 2011 02:31 AM

hmm, ok. So just to clarify, its not possible to show just the form to insert a new row into a matrix?

No, it’s not. That’s out of our realm, and is really up to the fieldtype developer. If you wanted, you could probably manually output the appropriate form fields yourself, but that’s easier said than done.

Also, I’m getting this JS error when displaying my matrix in the page:

TypeErrorResult of expression '$.ee_filebrowser' [undefined] is not a function. 

Can you post your full template code so we can diagnose?

Profile
 
 
Posted: 19 February 2011 02:36 AM   [ Ignore ]   [ # 10 ]
Teen Scream
Avatar
RankRankRank
Total Posts:  3541
Joined  2009-05-29

Also your EE version and your SafeCracker version #.

Profile
 
 
Posted: 19 February 2011 02:43 AM   [ Ignore ]   [ # 11 ]
Wallflower
Rank
Total Posts:  6
Joined  2011-02-19
Rob Sanchez - 19 February 2011 02:35 AM

Can you post your full template code so we can diagnose?

EE 2.1.3 / SafeCracker 1.0.3

Specific Error in Safari Version 5.0.3 (6533.19.4):

index.php:674 -- TypeErrorResult of expression '$.ee_filebrowser' [undefined] is not a function. 
<!doctype html>  

<!--
[if lt IE 7 ]> <html lang="en" class="no-js ie6"> <![endif]-->
<!--
[if IE 7 ]>    <html lang="en" class="no-js ie7"> <![endif]-->
<!--
[if IE 8 ]>    <html lang="en" class="no-js ie8"> <![endif]-->
<!--
[if IE 9 ]>    <html lang="en" class="no-js ie9"> <![endif]-->
<!--
[if (gt IE 9)|!(IE)]><!--> <html lang="en" class="no-js"> <!--<![endif]-->
<
head>
    <
meta charset="utf-8">
    <
meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

    <
title>LUVD Family</title>
    <
meta name="description" content="">
    <
meta name="author" content="">

    <
meta name="viewport" content="width=device-width, initial-scale=1.0">
    <
link rel="shortcut icon" href="/favicon.ico">
    <
link rel="apple-touch-icon" href="/apple-touch-icon.png">
    <
link rel="stylesheet" href="/styles/style.css?v=2">
    
[removed][removed]
</head>

<
body class="family">

    
{embed="includes/header"}
    
    
<div id="main" class="container">
        <
div class="inner">
            <
h1>{segment_1}</h1>
            
            
{exp:safecracker channel="family_photos" entry_id="19" safecracker_head="yes"}
                {field
:family_photos_images    }
            {
/exp:safecracker}
            
            
<section class="photos clearme">
                <
ul>
                    <
li>
                        <
img src="/images/ui/family/fpo-pic.jpg" width="136" height="136" alt="Fpo Pic">
                        <
div class="details">
                            <
span class="city">San Luis Obispo</span>
                            <
span class="state">California</span>
                            <
span>is LUVD</span>
                        </
div>
                    </
li>
                </
ul>
                <
a href="#" class="next">More</a>
            </
section>
            
        </
div>
    </
div>
    <
div id="overlay"><div class="title"></div><div class="close"></div></div>
    <
div id="overlay-screen"></div>
    
{embed="includes/footer"}
</body>
</
html
[ Edited: 19 February 2011 02:49 AM by garth ]
Profile
 
 
Posted: 19 February 2011 03:15 AM   [ Ignore ]   [ # 12 ]
Wallflower
Rank
Total Posts:  6
Joined  2011-02-19

Nevermind, I figured it out. I have all my scripts at the bottom of the page, and SC was expecting JQuery to be loaded already. Just need to defer it. Thanks.

Profile
 
 
Posted: 19 February 2011 04:31 AM   [ Ignore ]   [ # 13 ]
Wallflower
Rank
Total Posts:  6
Joined  2011-02-19
Rob Sanchez - 19 February 2011 02:35 AM
garth - 19 February 2011 02:31 AM

hmm, ok. So just to clarify, its not possible to show just the form to insert a new row into a matrix?

No, it’s not. That’s out of our realm, and is really up to the fieldtype developer. If you wanted, you could probably manually output the appropriate form fields yourself, but that’s easier said than done.

I got this working.. (might be the easier said than done route) in case anyone else tries to do this..

1. Get the input names of an unsaved row from the CP Matrix.
2. Add a hidden input named “field_id[row_order][]”, with a value of “row_new_0”.
3. Then add an input for whatever matrix fields you have, named “field_id[row_new_0][col_id_YY]”.

Here’s my code:

{exp:safecracker channel="family_photos" entry_id="19"}      
    
<input type="hidden" name="family_photos_images[row_order][]" value="row_new_0">
    <
input type="file" name="family_photos_images[row_new_0][col_id_12]" />
    <
input type="text" name="family_photos_images[row_new_0][col_id_13]" value="" placeholder="Your Name" />
    <
input type="text" name="family_photos_images[row_new_0][col_id_14]" value="" placeholder="Your City" />
    <
input type="text" name="family_photos_images[row_new_0][col_id_15]" value="" placeholder="Your State" />
    <
input type="submit" name="submit" value="Submit" />
{/exp:safecracker} 
[ Edited: 19 February 2011 04:39 AM by garth ]
Profile
 
 
Posted: 05 April 2011 01:38 AM   [ Ignore ]   [ # 14 ]
Wallflower
Rank
Total Posts:  6
Joined  2011-04-05

Iâ??m trying to create a project management section for my client. The idea is to create a project that allow users to update images, videos, docs, pdfs and text.

The sequence would go, create project. Then via a matrix, add project entries to the project. Which can be just a note, â??Updated the presentation for tomorrow. Emailed to clientâ?. Or â??The file download contains the new logo from the client.â? With a jpg or png that they uploaded via the project page.

In a nutshell, I want to be able to add new matrix rows to an existing channel entry. And not allowing guest to be able to delete or edit any existing matrix rows.

â??client_accessâ? is the channel. â??project_entryâ? is the name of the matrix. With the matrix cells being, â??post_title,â? â??post_by_name,â? â??post_note,â? â??post_image,â? and â??post_upload.â?

My code:

{exp:channel:entries channel="client_access" url_title="{segment_2}"}    
            
<div class="title">{title}</div

               
Project Start Date{entry_date format="%n / %j / %Y"}<br/>
               
{project_info}   
        
Post Project Entry
:<br/>
{exp:safecracker channel="client_access" return="/client_access/{segment_2}" url_title="{segment_2}"}  

Title
:<br/>  
<
input type="hidden" name="project_entry[row_order][]" value="row_new_0">
<
input name="project_entry[row_new_0][post_title]" type="text" value="" placeholder="Post Title" /><br/>    
Posted By:<br/> 
<
input name="project_entry[row_new_0][post_by_name]" type="text" value="" placeholder="Post By" /> <br/>  
Note:<br/>     
<
input name="project_entry[row_new_0][post_note]" type="text" style="width:100px; height:100px;" value="" placeholder="Note" /><br/>    
Upload Image:<br/> 
<
input type="file" name="project_entry[row_new_0][post_image]" size="40"><br/>
Upload FilePDFDocTxt<br/> 
<
input type="file" name="project_entry[row_new_0][post_upload]" size="40"><br/>    

<
input type="submit" value="Submit" />    
{/exp:safecracker} 
 
 Previous Project Entries
</br>
    
{project_entry}
       {post_title}
<br/>    
       
{post_by_name}<br/>
       
{post_note}<br/>
    
{/project_entry}
{
/exp:channel:entries} 

As shown above, I followed the above example. But, I canâ??t seem to get mine to work. I think Iâ??m missing something.

Thoughts?

Profile
 
 
Posted: 05 April 2011 01:47 AM   [ Ignore ]   [ # 15 ]
Teen Scream
Avatar
RankRankRank
Total Posts:  3541
Joined  2009-05-29

You have to get the col_id_X numbers instead of using your col names. Take a look at the example just above your post.

Profile
 
 
   
1 of 2
1