Jump to:

2011 Posts in 1436 Topics by 620 members

Form Questions

SilverStripe Forums » Form Questions » error take data from chackbox in email

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

Page: 1
Go to End
Author Topic: 1593 Views
  • bebabeba
    Avatar
    Community Member
    192 Posts

    error take data from chackbox in email Link to this post

    Hi!
    I send mail wit Email_Template.
    My problem is that I have a checkbox and I'm unable to print data in my email template because I have an error:

    ArrayData::__construct: Parameter needs to be an object or associative array
    At line 39 in E:\_silverstripe_cms\silverstripe\sapphire\core\ArrayData.php

    The proble is how write data in checkbox. Can you hel me?
    This is my checkbox:

    new CheckboxSetField(
                $name = "topics",
                $title = "Settori d'interesse:",
                $source = array(
                 "1" => "Information Management",
                 "2" => "Application Integration (EAI)",
                 "3" => "System Management",
                 ),
                $value = ""
                   )

    and in GenericEmail.ss I wrote: Settori d'interesse: $topics

  • bebabeba
    Avatar
    Community Member
    192 Posts

    Re: error take data from chackbox in email Link to this post

    any one??

  • Fuzz10
    Avatar
    Community Member
    787 Posts

    Re: error take data from chackbox in email Link to this post

    I think the form returns an array ... So depending on what you need to do , you could either implode it into a string (for , say , displaying it in a mail) and feed it to the template or convert it into viewable data for Silverstripe using ArrayData() ...

    See:
    http://doc.silverstripe.com/doku.php?id=arraydata&s=arraydata

    or

    http://doc.silverstripe.com/doku.php?id=tutorial:3-forms&s=arraydata

    Good luck !

  • bebabeba
    Avatar
    Community Member
    192 Posts

    Re: error take data from chackbox in email Link to this post

    Sorry but I'm unable..I'm not able to show the result of my checkbox in my e-mail

    $e = new Email_Template();
          $e->From = "xx@xx.com";
          $e->To = "xx@xx.it";
          $e->populateTemplate($data);
          
          $e->Subject = "Hi there";
          $e->Body = "I just really wanted to email you and say hi.";*/
          $e->send();

    Where $data contain all data in my form also checkbox

  • Fuzz10
    Avatar
    Community Member
    787 Posts

    Re: error take data from chackbox in email Link to this post

    Well.. A very easy way is converting the values to a string .. ;-)

    e.g. :

    $data['Checkbox_String'] = implode("<br/>",$data['Checkboxes']);

    1593 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.