Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Form Questions /

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

Newsletter Subscribe Form problem


Go to End


4 Posts   1072 Views

Avatar
nonetalaga2

Community Member, 5 Posts

9 July 2010 at 3:23pm

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

Avatar
swaiba

Forum Moderator, 1899 Posts

13 July 2010 at 10:05am

Got any code for this?

Avatar
nonetalaga2

Community Member, 5 Posts

15 July 2010 at 5:14pm

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 %>

Avatar
swaiba

Forum Moderator, 1899 Posts

15 July 2010 at 7:32pm

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