I’m Having Difficulty Displaying my Custom Fields
Posted: 16 September 2010 10:14 PM   [ Ignore ]
Wallflower
Rank
Total Posts:  17
Joined  2010-08-24

The difficulty is that they’re not displaying… Everything else looks right, though!

Here’s my template code:

{embed="site/.header"}


    
<link href="{path=css/_ee_saef_css}" type="text/css" rel="stylesheet" media="screen" />
    
{exp:jquery:script_tag}
    {exp
:jquery:script_tag ui="datepicker"}

    {exp
:safecracker
     channel
="safecracker"
     
logged_out_member_id="10"
     
return="safecracker/create-entry/URL_TITLE"
     
url_title="{segment_3}"}

        
<label for="title">Title</label>
        <
input type="text" name="title" id="title" value="{title}" size="50" maxlength="100">

        <
label for="url_title">URL Title</label>
        <
input type="text" name="url_title" id="url_title" value="{url_title}" maxlength="75" size="50" />

        
{status_menu}
            
<label for="status">Status</label>
            <
select name="status" id="status">
            
{select_options}
            
</select>
        
{/status_menu}

        
<label for="entry_date">Date</label>
        <
input type="text" name="entry_date" id="entry_date" value="{entry_date}" maxlength="23" size="25" />

        <
label for="expiration_date">Expiration Date</label>
        <
input type="text" name="expiration_date" id="expiration_date" value="{expiration_date}" maxlength="23" size="25" />

        <
label for="comment_expiration_date">Comment Expiration Date</label>
        <
input type="text" name="comment_expiration_date" id="comment_expiration_date" value="{comment_expiration_date}" maxlength="23" size="25" />

        <
label class="checkbox"><input type="checkbox" name="sticky" value="y"  {sticky} /> Make Entry Sticky</label><br />
        <
label class="checkbox"><input type="checkbox" name="allow_comments" value="y" {allow_comments} /> Allow Comments</label><br />
        <
label class="checkbox"><input type="checkbox" name="dst_enabled" value="y" {dst_enabled} /> DST Active on Date of Entry</label>

        
{category_menu}
            
<label for="categories">Categories</label>
            <
select name="category[]" id="categories" size="4" multiple="multiple">
            
{select_options}
            
</select>
        
{/category_menu}
        
        
<h3>Custom Fields</h3>
                
{if checkbox}
            
<select name="checkboxes" id="checkboxes">
            
{options:checkboxes}
                
<option value="{option_value}"{selected}>{option_name}</option>
            
{/options:checkboxes}
            
</select>
        
{/if checkbox}
    
        {safecracker
-matrix}{/safecracker-matrix}

        {field
:wygwam}

        {if captcha}
            
<label for="captcha">Please enter the word you see in the image below:</label
            {captcha}
            
><input type="text" name="captcha" value="{captcha_word}" maxlength="20" />
        
{/if}

        
<input type="submit" name="submit" value="Submit" />

    
{/exp:safecracker}


{embed
="site/.footer"

The field names are correct; I named them after the fieldtypes so I wouldn’t have to keep referencing my CP while I tested this sucker out.

I tried wrapping my custom fields in the {custom_fields}{/custom_fields} tags as well, but got the same result.

Profile
 
 
Posted: 16 September 2010 10:22 PM   [ Ignore ]   [ # 1 ]
Teen Scream
Avatar
RankRankRank
Total Posts:  3541
Joined  2009-05-29

If you are not using the custom fields tag pair, you have to use the field name (not type) to show your custom field. Within the custom_fields tag pair, you use conditionals with the field type. Also, the syntax for displaying fields is a little different. So:

<h3>Custom Fields</h3>
{custom_fields}
    {if checkbox}
        {options}
<label class="checkbox">{option_value} <input type="checkbox" id="{field_name}" name="{field_name}[]" value="{option_value}"{checked} /></label>{/options}
    {
/if}
        {if matrix}
            {display_field}
        {
/if}
        {if wygwam}
            {display_field}
        {
/if}
{
/custom_fields} 

Or you can do this:

<h3>Custom Fields</h3>
        
{options:your_checkbox_field_name}
            
<label class="checkbox">{option_value} <input type="checkbox" id="your_checkbox_field_name" name="your_checkbox_field_name[]" value="{option_value}"{checked} /></label>
        
{/options:your_checkbox_field_name}
        {field
:your_matrix_field_name}
        {field
:your_wygwam_field_name}
{
/custom_fields} 

They’ll both output essentially the same thing.

[ Edited: 05 November 2010 08:34 PM by Rob Sanchez ]
Profile
 
 
Posted: 16 September 2010 10:36 PM   [ Ignore ]   [ # 2 ]
Wallflower
Rank
Total Posts:  17
Joined  2010-08-24

Thanks. Discovered that I forgot to add the fields to the channel…

Got it working now.

Profile
 
 
Posted: 04 November 2010 10:12 PM   [ Ignore ]   [ # 3 ]
Wallflower
Rank
Total Posts:  11
Joined  2010-09-21

For anyone else who reads this post!

I got Wygwam to work only after setting the parameter “safecracker_head=“yes”. (which is the default - I’d previously set it to ‘no’)
A frustrating 45 minutes but hope it helps someone else.

John

Profile
 
 
Posted: 04 November 2010 10:17 PM   [ Ignore ]   [ # 4 ]
Teen Scream
Avatar
RankRankRank
Total Posts:  3541
Joined  2009-05-29

Yep. I’m pretty sure all the Pixel and Tonic fieldtypes (except P&T Field Pack): Matrix, Playa, Wygwam and Dive Bar, are dependent on safecracker_head.

Profile