Jump to:

10843 Posts in 2513 Topics by 1792 members

All other Modules

SilverStripe Forums » All other Modules » User Forms pdf version and email submissions

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 2206 Views
  • karibe
    Avatar
    Community Member
    56 Posts

    User Forms pdf version and email submissions Link to this post

    Hello

    I'm using that module to receive some pretty complicated polls from the people. When someone will submit such poll we should get completed form
    in pdf version as email attachment. What is the simplest way to do that?
    As I saw in email body "Spam protection field" is included as "EditableLiteralField77". How to disable it in email body
    By contrast "HTML Block" isn't visible in email body but it should.

  • karibe
    Avatar
    Community Member
    56 Posts

    Re: User Forms pdf version and email submissions Link to this post

    So maybe someone knows how to display in submitted email "HTML Block" content value? As I see in userforms/templates/email/SubmittedFormEmail.ss

    <h1>$Subject</h1>
    $Body

    <% if HideFormData = 1 %>
    <% else %>
       <dl>
          <% control Fields %>
             <dt><strong><% if Title %>$Title<% else %>$Name<% end_if %></strong></dt>
             <dd style="margin: 4px 0 14px 0">$Value</dd>
          <% end_control %>
       </dl>
    <% end_if %>


    dd shows $Value but value for "HTML Block" userforms/code/editor/EditableLiteralField.php is name of the field.
    How can I display Field Configuration>HTML content?

    Where I find some user forms development resources?

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: User Forms pdf version and email submissions Link to this post

    but value for "HTML Block" userforms/code/editor/EditableLiteralField.php is name of the field.

    It shouldn't be calling $Value on the EditableLiteralField, rather value on the SubmittedFormField object - Does that have the incorrect content? Maybe when saving the form it saves the name rather then the content but I'm pretty sure its not a display issue.

  • karibe
    Avatar
    Community Member
    56 Posts

    Re: User Forms pdf version and email submissions Link to this post

    Here is the concept.
    People are submitting their statements and then when they receive on submitted email a pdf copy, they have to print it, sign it and bring to us.
    The problem is that beside common fields like "Text field" I have two that make a problem. Spam protection field which is visible in email as "EditableLiteralField77" and "HTML block". "HTML Block" is used to display some agreement conditions that have to be signed. HTML looks like

    <ul>
    <li>condition1 </li>
    <li>condition2</li>
    <li>condition3</li>
    <li>condition4</li>
    </ul>

    Unfortunately In email I see only "Conditions" label.

    When I correct that issue next is to attach pdf with form content same as in email:-) As I lookup there is no finished solution, so I'll have to write it myself. Thus maybe You as an module author could prompt me with most elegant method?

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: User Forms pdf version and email submissions Link to this post

    Oh right yes, you won't see the HTMLBlock content since the content for it won't actually get submitted in the form (since its readonly, not an editable version - It should actually not even include any htmlblock fields in the email as per how its currently designed but its a bug its showing the title).

    If you want to include the content you can define a function getValueFromData() on the form field which will set the value in the email.

    So you can either edit the core EditableLiteralField.php (and remember to readd this function when you upgrade) or you can apply the following function as a dataobject decoration

    function getValueFromData($data) {
    // return the content from the field rather that anything from the data array
    return $this->getSetting('Content');
    }

  • karibe
    Avatar
    Community Member
    56 Posts

    Re: User Forms pdf version and email submissions Link to this post

    Works, but html is not parsed:-(

  • karibe
    Avatar
    Community Member
    56 Posts

    Re: User Forms pdf version and email submissions Link to this post

    Problem solved
    In pdf attachment issue I've added in UserDefinedForm_EmailRecipient

       static $db = array(
          'EmailAddress' => 'Varchar(200)',
          'EmailSubject' => 'Varchar(200)',
          'EmailFrom' => 'Varchar(200)',
          'EmailBody' => 'Text',
          'SendPlain' => 'Boolean',
          'PdfAttachment' => 'Boolean',
          'HideFormData' => 'Boolean'
       );


    and

          $fields = new FieldSet(
             new TextField('EmailSubject', _t('UserDefinedForm.EMAILSUBJECT', 'Email Subject')),
             new TextField('EmailFrom', _t('UserDefinedForm.FROMADDRESS','Send Email From')),
             new TextField('EmailAddress', _t('UserDefinedForm.SENDEMAILTO','Send Email To')),
             new CheckboxField('HideFormData', _t('UserDefinedForm.HIDEFORMDATA', 'Hide Form Data from Email')),
             new CheckboxField('SendPlain', _t('UserDefinedForm.SENDPLAIN', 'Send Email as Plain Text (HTML will be stripped)')),
             new CheckboxField('PdfAttachment', _t('UserDefinedForm.PDFATTACHMENT', 'Add Form Data as PDF attachment')),
             new TextareaField('EmailBody', 'Body')
          );

    Now plan is to modify method process in UserDefinedForm_Controller

  • Indika
    Avatar
    Community Member
    3 Posts

    Re: User Forms pdf version and email submissions Link to this post

    if you want to generate pdf , you can use html2pdf library . for more information please read my blog
    http://indikagamage.com/blog/how-to-html-to-pdf-in-silverstripe/

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