ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

SafeCracker same type field displaying twice

January 24, 2012 10:05pm

Subscribe [2]
  • #1 / Jan 24, 2012 10:05pm

    EnergyFreak

    102 posts

    Hi,

    I think I found a bug in SafeCracker. For some reason my “text input” custom fields are displaying twice…

    This is what I have:

    {custom_fields} 
    
     {if professor}
      <label for="professor">Professor</label>
                    <input type="text" dir="{text_direction}" id="professor" name="professor" value="{field_data}" maxlength="{maxlength}" size="45" field_name="professor"></p>
      {error:professor}
     {/if}
    
     {if file_upload}
             label for="upload">Upload file:</label>
             <input type="file" name="file_upload" id="file_upload" /></p>
     {/if}
     
     {if price}
      <label for="price">Credit Cost</label>
                    <input type="text" dir="{text_direction}" id="price" name="price" value="{field_data}" maxlength="{maxlength}" size="45" field_name="price"></p>
      {error:price}
     {/if}
    
     {if type}
      <label for="type">Type</label>
                    <select id="type" name="type"
                            {options}<option value="{option_value}"{selected}>{option_name}</option>{/options}
                    </select>
      {error:type}
            {/if}
    
    
     {if tag}
      <label for="tags">Add Tags (Press enter to add a tag)</label>
                    {exp:tag:entry_widget all_open=“no” field_name="tag"} 
      {error:tag}
    
     {/if}
     
    
         {/custom_fields}

    Inside the safecracker brackets of course. Everything else displays normally and in the the order selected in the control panel, except the two text input fields who duplicate for some odd reason at both field order locations(1st and 4th)... Like if they were linked together…

  • #2 / Jan 25, 2012 5:39pm

    EnergyFreak

    102 posts

    Let me explain this with a diagram of how my custom fields are displaying:

    21     Professor     1     Text Input 
    15     File Upload   2     SafeCracker File 
    19     Price         3     Text Input 
    18     Type          4     Select Dropdown 
    17     Tag           5     Tag

    Do you see the order and the fieldtype? Once my template is rendered the field called “Professor” is rendered at two places, 1 and 3 and the same applies for “Price” which is rendered at 3 and 1. Therefore duplicating my fields…

    My question still hasn’t been answered and I see that many questions that were asked before me got an answer… This is extremely important and it is slowing down my launch. I need to know if it is a bug or if I am doing something wrong.

    Thanks.

  • #3 / Jan 26, 2012 3:00pm

    Shane Eckert

    7174 posts

    EnergyFreak,

    Thank you for posting on the ExpressionEngine forums.

    I would approach this a little differently.

    Safecracker has a few built in variables that you can use to make it more dynamic. You would only call this once and get both instances of the text field.

    {if text}
    <label for="{field_name}">{field_name}</label>
    <input type="text" dir="{text_direction}" id="{field_name}" name="{field_name}" value="{field_data}" maxlength="{maxlength}" size="50"><br>
    {error:{field_name}}
    {/if}

    Does this make sense?

    Cheers!

  • #4 / Jan 26, 2012 4:04pm

    EnergyFreak

    102 posts

    Yes that fixed the problem. This should be added to the documentation though to remove confusion. It doesn’t say anywhere in the documentation what to do in case you have multiples of the same field type. If it does then ignore what I just said.

    Thanks for your help !

  • #5 / Jan 27, 2012 3:48am

    Shane Eckert

    7174 posts

    Hi EnergyFreak,

    I am glad it is working for you now.

    I will look closely at the docs and see if we need to make some changes. Thanks for posting!

    Regards,

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases