Hidden Relationship Field
Posted: 22 March 2011 05:34 PM   [ Ignore ]
Has a Great Personality
Rank
Total Posts:  41
Joined  2010-11-08

Guys

I know safercracker has been passed over to mainstream EE and I have logged this there too.  But you are always very quick woth support so I thought I would chance my arm.

I have an edit SAEF form than when I submit the form I get an error and I have working this out that it is because I have a standard EE relationship field and I have not got this in the form.  I don’t want this field changed or editable so I think I need to have it as a hidden field but just not sure how this is done.

Any ideas

Thanks

Profile
 
 
Posted: 22 March 2011 08:15 PM   [ Ignore ]   [ # 1 ]
Teen Scream
Avatar
RankRankRank
Total Posts:  3541
Joined  2009-05-29

You should just be able to include a hidden input with the entry_id of the entry you are automatically relating it to:

<input type="hidden" name="your_relationship_field" value="123" /> 
Profile
 
 
Posted: 22 March 2011 08:21 PM   [ Ignore ]   [ # 2 ]
Has a Great Personality
Rank
Total Posts:  41
Joined  2010-11-08

so would I have this

<input type="hidden" name="club" value="{entry_id}" /> 
Profile
 
 
Posted: 22 March 2011 08:32 PM   [ Ignore ]   [ # 3 ]
Teen Scream
Avatar
RankRankRank
Total Posts:  3541
Joined  2009-05-29

Well, that {entry_id} would be the ID of the entry you’re currently editing, so that’s probably not what you want.

Profile
 
 
Posted: 22 March 2011 08:33 PM   [ Ignore ]   [ # 4 ]
Has a Great Personality
Rank
Total Posts:  41
Joined  2010-11-08

Now I get it, I have tested it with just using the entry_id of the proper club.

I’m still learning this so bear with me.  Surely with the channel players I should be able to use a variable as the value rather than the actual number.  But where do I get than from and what should it be.

{exp:safecracker channel="players" return="clubhouse/index" url_title="{segment_3}"}

                
<input type="hidden" name="player_club" value="6793" />

                <
fieldset>
                    <
div>
                        <
label for="player_name">Player Name</label>
                        <
input type="text" name="title" id="title" value="{title}" />
                    </
div>
                
                    <
div>
                        <
label for="measurements">Measurements</label>
                        
{field:player_measurements}
                    
</div>

                    <
div>
                        <
label for="player_bio">bio</label>
                        
{field:player_bio}
                    
</div>
                    
                    <
div>        
                    
{category_menu}
                        
<label for="categories">Position</label>
                            <
select name="category[]" id="categories" size="4" multiple="multiple">
                            
{select_options}
                            
</select>
                    
{/category_menu}
                    
</div>

                    <
button type="submit" name="submit">Update</button>

                </
fieldset>
                
{/exp:safecracker} 
Profile
 
 
Posted: 22 March 2011 08:45 PM   [ Ignore ]   [ # 5 ]
Teen Scream
Avatar
RankRankRank
Total Posts:  3541
Joined  2009-05-29

How do you decide with club the player belongs to?

Profile
 
 
Posted: 22 March 2011 08:51 PM   [ Ignore ]   [ # 6 ]
Has a Great Personality
Rank
Total Posts:  41
Joined  2010-11-08

I have an EE relationship field to club channel and at the moment this can only be changed via the Control Panel.

Profile
 
 
Posted: 22 March 2011 08:55 PM   [ Ignore ]   [ # 7 ]
Has a Great Personality
Rank
Total Posts:  41
Joined  2010-11-08

Trying to do to much at once and wasn’t thinking.

I can use my custom member field exec_club that I store the entry_id for the club.

Profile
 
 
Posted: 22 March 2011 08:55 PM   [ Ignore ]   [ # 8 ]
Teen Scream
Avatar
RankRankRank
Total Posts:  3541
Joined  2009-05-29

Gotcha, I think I understand now. I think this will do the trick:

{exp:query sql="SELECT rel_child_id FROM exp_relationships WHERE rel_id='{player_club}' LIMIT 1"}
                
<input type="hidden" name="player_club" value="{rel_child_id}" />
{/exp:query} 
Profile
 
 
Posted: 22 March 2011 09:07 PM   [ Ignore ]   [ # 9 ]
Has a Great Personality
Rank
Total Posts:  41
Joined  2010-11-08

Many Thanks

Profile