Using Form Helper with Custom Fields loop
Posted: 27 March 2008 12:06 AM   [ Ignore ]
Newbie
Rank
Total Posts:  15
Joined  2007-09-15

Seems like this ought to work, yet none of my fields get populated.  My Title field is being populated, but its above the custom fields loop.

{custom_fields}

         
<tr><td class="title">{if required}<span class="redstar">*</span>{/if}{field_label}:</td>
          <
td>

           
{if textarea}
           
<textarea id="{field_name}" name="{exp:form_helper:field_grabber field_name='{field_name}'}" cols="40" rows="{rows}">{field_data}</textarea>
           
{/if}

           {if textinput}
           
<input type="text" id="{field_name}" value="{field_data}" name="{exp:form_helper:field_grabber field_name='{field_name}'}" maxlength="{maxlength}" size="30" />
           
{/if}

           {if pulldown}
            
<select name="{exp:form_helper:field_grabber field_name='{field_name}'}">
             
{exp:form_helper:custom_pulldown entry_id="{entry_id}" field_name="{field_name}"}
             
<option value="{value}" {selected}>{value}</option>
             
{/exp:form_helper:custom_pulldown}
            
</select>
           
{/if}

          
</td>
         </
tr>

         <
tr><td>&nbsp;</td><td class="formhelp">{field_instructions}</td></tr>

        
{/custom_fields}


        
<tr><td colspan="2" class="continue"><input type="submit" name="bSubmit" value="Update" /></td></tr>
       </
table>

      
{/exp:weblog:entry_form}

Thanks,
Chad

Profile
 
 
Posted: 27 March 2008 06:33 AM   [ Ignore ]   [ # 1 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  3350
Joined  2006-10-18

I’ve never actually tested this out using it this… only hardcoded…

Can I assume you have this at the beginning of your form? smile

{exp:weblog:entries rdf="off"}
{exp
:weblog:entry_form weblog="your_weblog" return="template_group/template"}
<input type="hidden" name="entry_id" value="{entry_id}" />

You should probably also use {field_name} instead of {field_data}

 Signature 
Profile
 
 
Posted: 27 March 2008 08:30 AM   [ Ignore ]   [ # 2 ]
Newbie
Rank
Total Posts:  15
Joined  2007-09-15

Here is the entire form

<h1>My Company Profile</h1>
    
    
    
{exp:weblog:entries weblog="companies" disable="category_fields|member_data|pagination|trackbacks" rdf="off" author_id="CURRENT_USER" limit="1"}

     {if no_results}  
      
<!-- Show the entry form -->
      
       
{Company Profile Entry}
     
       {exp
:weblog:entry_form weblog="companies" return="account" use_live_url="no" category="9"}

        
<table class="formtable">
         <
tr><td></td><td class="required-info"><span class="redstar">*</span> Required information</td></tr>

         <
tr><td class="title"><span class="redstar">*</span>Company Name:</td>
          <
td>
           <
input type="text" name="title" value="" id="title" size="30" />
          </
td>
         </
tr>


         
{custom_fields}

          
<tr><td class="title">{if required}<span class="redstar">*</span>{/if}{field_label}:</td>
           <
td>

            
{if textarea}
            
<textarea id="{field_name}" name="{field_name}" cols="40" rows="{rows}">{field_data}</textarea>
            
{/if}

            {if textinput}
            
<input type="text" id="{field_name}" name="{field_name}" maxlength="{maxlength}" size="30" />
            
{/if}

            {if pulldown}
             
<select id="{field_name}" name="{field_name}">
              
{options}<option value="{option_value}"{selected}>{option_name}</option>{/options}
             
</select>
            
{/if}

           
</td>
          </
tr>

          <
tr><td>&nbsp;</td><td class="formhelp">{field_instructions}</td></tr>

         
{/custom_fields}


         
<tr><td colspan="2" class="continue"><input type="submit" name="bSubmit" value="Submit" /></td></tr>
        </
table>

       
{/exp:weblog:entry_form}
     
     
     {
/if} <!-- no_entries -->

(more below)

Profile
 
 
Posted: 27 March 2008 08:31 AM   [ Ignore ]   [ # 3 ]
Newbie
Rank
Total Posts:  15
Joined  2007-09-15

<!-- show the edit form -->
      
      
{Company Profile Edit}
      
      {exp
:weblog:entry_form weblog="companies" return="account"}
       
<input type="hidden" name="entry_id" value="{entry_id}" />
       <
input type="hidden" name="title" value="{title}" />
       <
input type="hidden" name="entry_date" value="{entry_date format='%Y-%m-%d %g:%i %A'}" />
       <
input type="hidden" name="category[]" value="{cat_id}" />
      
      
      
       <
table class="formtable">
        <
tr><td></td><td class="required-info"><span class="redstar">*</span> Required information</td></tr>

        <
tr><td class="title"><span class="redstar">*</span>Company Name:</td>
         <
td>
          <
input type="text" name="title" value="{title}" id="title" size="30" />
         </
td>
        </
tr>


        
{custom_fields}

         
<tr><td class="title">{if required}<span class="redstar">*</span>{/if}{field_label}:</td>
          <
td>

           
{if textarea}
           
<textarea id="{field_name}" name="{exp:form_helper:field_grabber field_name='{field_name}'}" cols="40" rows="{rows}">{field_data}</textarea>
           
{/if}

           {if textinput}
           
<input type="text" id="{field_name}" value="{field_data}" name="{exp:form_helper:field_grabber field_name='{field_name}'}" maxlength="{maxlength}" size="30" />
           
{/if}

           {if pulldown}
            
<select name="{exp:form_helper:field_grabber field_name='{field_name}'}">
             
{exp:form_helper:custom_pulldown entry_id="{entry_id}" field_name="{field_name}"}
             
<option value="{value}" {selected}>{value}</option>
             
{/exp:form_helper:custom_pulldown}
            
</select>
           
{/if}

          
</td>
         </
tr>

         <
tr><td>&nbsp;</td><td class="formhelp">{field_instructions}</td></tr>

        
{/custom_fields}


        
<tr><td colspan="2" class="continue"><input type="submit" name="bSubmit" value="Update" /></td></tr>
       </
table>

Profile
 
 
Posted: 27 March 2008 02:40 PM   [ Ignore ]   [ # 4 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  3350
Joined  2006-10-18

Have you tried it with using {field_name} instead of {field_data}? smile

 Signature 
Profile
 
 
Posted: 27 March 2008 04:46 PM   [ Ignore ]   [ # 5 ]
Newbie
Rank
Total Posts:  15
Joined  2007-09-15

field_name yields form fields with “field_id_xx” in the textbox/textarea.  I can definitely hard code it- was hoping this would work almost as a scaffolding.

Is Reuben-Burger man in the house? wink

Profile
 
 
Posted: 27 March 2008 04:48 PM   [ Ignore ]   [ # 6 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  3350
Joined  2006-10-18

Haha… yeah, I think Hardcoded is the only way to go wink

 Signature 
Profile
 
 
Posted: 28 April 2008 01:23 PM   [ Ignore ]   [ # 7 ]
Newbie
Rank
Total Posts:  5
Joined  2006-09-05

Can someone help me “hard code” this? I’m in the exact situation here.

Profile
 
 
Posted: 28 April 2008 01:34 PM   [ Ignore ]   [ # 8 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  3350
Joined  2006-10-18

David,

If you’re after Hardcoding the SAEF, have a look at this thread: smile

http://www.solspace.com/forums/viewthread/836/

 Signature 
Profile
 
 
Posted: 28 April 2008 01:38 PM   [ Ignore ]   [ # 9 ]
Newbie
Rank
Total Posts:  5
Joined  2006-09-05

Oh, I see. So you just mean not using the custom fields loop? I think I understand. I was thinking there was a nifty way to use the custom fields loop with the Form Helper plugin. It looks like I’ll have to go the standard route.

Thanks for the advice.

Profile
 
 
Posted: 28 April 2008 01:44 PM   [ Ignore ]   [ # 10 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  3350
Joined  2006-10-18

David,

Correct. You cannot use the Custom Fields variable pair within the Formhelper loop. smile
Here’s another post on hardcoded editing with Formhelper:

http://www.solspace.com/forums/viewthread/846/

 Signature 
Profile