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.

Comment-form: Optional name field?

March 16, 2011 6:53pm

Subscribe [3]
  • #1 / Mar 16, 2011 6:53pm

    Victoriaz

    19 posts

    Hi

    I would like to make ‘name’ as an optional field. If unregistered users want to put comments they can do. However they will have the option of putting their name.

    A working version of the code below would be much appreciated. Thanks

    {exp:comment:form channel="{channel_name}” form_class=“comment_form” entry_status=“not draft|pending|closed”}
      {if logged_out} 
    <input type=“text” name=“name” value=”{name}”/>
    {if name ==""}
      {name = 'anonymous'}
    {/if}
          <input type=“hidden” name=“email” value=“[email protected]” />
          <textarea name=“comment”>{comment}</textarea>
          <input type=“submit” id=“comment-submit” value=“Post  your comment!” class=“button_input” name=“submit”> 
                 
      {if:else}
         
          <textarea name=“comment”>{comment}</textarea>
          <input type=“submit” id=“comment-submit” value=“Post  your comment!” class=“button_input” name=“submit”>
      {/if}
    {/exp:comment:form}
    Moved to CodeShare Corner by Moderator

  • #2 / Mar 17, 2011 12:19pm

    Brandon Jones

    5500 posts

    Hi Victoriaz,

    EE does expect the name field from guests, so I’d suggest a simple bit of jQuery to insert a generic name if needed during the form submission event. If you’d like I can move this over to the CodeShare Corner to get you help with that; just let me know.

  • #3 / Mar 17, 2011 12:23pm

    Victoriaz

    19 posts

    Hi Brandon,

    Thanks for getting back to me on this post.
    Yes, if you could do that that would be great.

  • #4 / Mar 17, 2011 6:44pm

    Sue Crocker

    26054 posts

    Moving to CodeShare Corner…

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

ExpressionEngine News!

#eecms, #events, #releases