Jump to:

2012 Posts in 1438 Topics by 621 members

Form Questions

SilverStripe Forums » Form Questions » Custom Email Form

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

Page: 1
Go to End
Author Topic: 1130 Views
  • andria
    Community Member
    7 Posts

    Custom Email Form Link to this post


    I made a custom email form that I output in my homepage page type
    in order for users to subscribe to a newsletter.
    The problem is I want the submit button to be an image which I have it
    uploaded in my theme images folder. I made the necessary class 'Eform'
    in the form.css stylesheet and put the class in the div where the form
    is supposed to appear in homepage.ss, but the submit button refuses
    to appear as the image defined in the class 'Eform' as background.
    Ca somebody help me out please?

    class HomePage_Controller extends Page_Controller {

    private $defaultGroupID = 4;

    function EmailForm() {
    return new Form($this, "EmailForm", new FieldSet(

             // List your fields here
             new EmailField("Email", "Email address")

          ), new FieldSet(

             // List the action buttons here
             new FormAction("SignupAction", "Sign up")

          ), new RequiredFields("Email"));

       * This function is called when the user submits the form.
       function SignupAction($data, $form) {

          // Create a new Member object and load the form data into it
          $member = new Member();

          // Write it to the database. This needs to happen before we add it to a group

          // Add the member to group. (Check if it exists first)
          if($group = DataObject::get_one('Group', "ID = $this->defaultGroupID")) {

             // Redirect to a page thanking people for registering


             // Redirect to a failure page




    ***HomePage.ss*** from Layout folder
    <div id="Newsletter">
              <div id="Newsletterform" class="Eform">

    .Eform input.action {
       padding: 2px;
       background: ../images/submit-button.png;
       width: 35px;
       height: 35px;
       text-indent: -999em;
       border: none;
    .Eform input.action:hover,
    .Eform input.action:focus {
       cursor: pointer;

    Have a nice day!

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.