Jump to:

2002 Posts in 1422 Topics by 616 members

Form Questions

SilverStripe Forums » Form Questions » Newsletter Subscribe Form problem

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 766 Views
  • nonetalaga2
    Avatar
    Community Member
    5 Posts

    Newsletter Subscribe Form problem Link to this post

    When I tried to subscribe it always return a required error "Subscribe to the lists" is required. Is there any solution?

  • swaiba
    Avatar
    Forum Moderator
    1784 Posts

    Re: Newsletter Subscribe Form problem Link to this post

    Got any code for this?

  • nonetalaga2
    Avatar
    Community Member
    5 Posts

    Re: Newsletter Subscribe Form problem Link to this post

    On the code part this is the code:
       
    function ShowForm(){
          $get = DataObject::get_one('UserDefinedForm', "URLSegment = 'newsletter'");
          return new UserDefinedForm_Controller($get);
       }   

    On the template part this is the code:

    <% control ShowForm %>
    <tr>
    <td>
          $Showform.Content
          $Showform.Form
       </td>
    </tr>   
    <% end_control %>

  • swaiba
    Avatar
    Forum Moderator
    1784 Posts

    Re: Newsletter Subscribe Form problem Link to this post

    Ok so you are using the User Defined Form? If so you should raise this under the modules section. If you were using a regular form...

    //create or find Member dataobject $doMember

    // Add the member to group. (Check if it exists first)
    if($group = DataObject::get_one('Group', "Code = 'Newsletter'"))
    {
    $doMember->Groups()->add($group);
    }

    .. this is the bit of code that finds the security group 'Newsletter' and then adds the member to it.

    Hope this helps,

    Barry

    766 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.