Jump to:

10979 Posts in 2722 Topics by 1815 members

All other Modules

SilverStripe Forums » All other Modules » UserForms 0.2

Discuss all other Modules here.

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

Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
Go to End
Author Topic: 27173 Views
  • Juanitou
    Avatar
    Community Member
    323 Posts

    Re: UserForms 0.2 Link to this post

    As reported by Kateh, translated forms are not working when upgrading: no fields can be added and no email recipients (error: I can't handle sub-URLs of a CMSMain object).

    Nevertheless, you can create a new translation of the form and adding fields should work, the problem is you can't see them in the published page.

    SOLUTION: Changing by hand the ParentID of the fields in the EditableFormField table. I'm sure willr will correct the faulty code in a blink!

  • Paschka
    Avatar
    Community Member
    4 Posts

    Re: UserForms 0.2 Link to this post

    Didn't solve my problem. switched everthing back to en_US. Still a white page with Submit-Button and no fields

  • Juanitou
    Avatar
    Community Member
    323 Posts

    Re: UserForms 0.2 Link to this post

    Hi!

    In order to work it here with 2.3.2, I downloaded several days ago userforms trunk (80961). Then I created a new contact form in the default language, then a translation, then Email recipients for both. Finally I manually updated the ParentID in EditableFormField table and the FormID in the UserDefinedForm_EmailRecipient table.

    That's all. Kate, did you tried starting from scratch and manually updating the database?

    Good luck,
    Juan

  • Thermalzombie
    Avatar
    Community Member
    27 Posts

    Re: UserForms 0.2 Link to this post

    Hi can somebody post a new link none seem to work? does it come with updated install instructions.

  • Willr
    Avatar
    Forum Moderator
    5497 Posts

    Re: UserForms 0.2 Link to this post

  • Big Bang Creative
    Avatar
    Community Member
    92 Posts

    Re: UserForms 0.2 Link to this post

    I'm not sure if this is possible.... I want to change the html outputted by the form. I'd really like to put the form filelds in an unordered list. How easy would this be to do?

  • Juanitou
    Avatar
    Community Member
    323 Posts

    Re: UserForms 0.2 Link to this post

    Hi!

    It's quite easy, I've just done it, but I'm quite sure it can be done even easier.

    In /templates/email/ folder you have SubmittedFormEmail.ss, where you can use something like:

    <% control Fields %>
    <ul>
       <li><span class="emphasis">$Title</span>:
             <% if Value = on %>
             Yes
             <% else %>
             $Value
             <% end_if %>
       </li>
    </ul>
    <% end_control %>

    If you want to use specific templates, the only way I have found is to to create a new Page type where you subclass UserDefinedForm, UserDefinedForm_controller and Email (look at UserDefinedForm.php). In MyFantasticUserDefinedForm_controller you must have a process() method where you replace:

       $email = new UserDefinedForm_SubmittedFormEmail($submittedFields);


    …with the name of the custom Email subclass.

    In this custom process() method you can add data to your email template via the $emailData array, e.g.:

       $emailData = array(
          "Sender" => Member::currentUser(),
          "Fields" => $submittedFields,
          // Added for sending different messages to clients and admin
          "ForAdmin" => true
       );


    Then, for example where it says later:

       if($recipient->SendEmailFromFieldID) {
          
          // Used in template if for hiding form fields from clients
          $emailData['ForAdmin'] = false;


    Then, in your custom email template:

       <h2>$Subject</h2>
       $Body
       <% if ForAdmin %>
       <% control Fields %>
       <p>
          <span class="emphasis">$Title</span></br>
          <% if Value %>
          <% if Value = --choissisez-- %>
          <span style="color:red">Non renseigné</span>
          <% else %>
          $Value
          <% end_if %>
          <% else %>
          <span style="color:red">Non renseigné</span>
          <% end_if %>
       </p>
       <% end_control %>
       <% end_if %>

    In this way, the admin receives a message with all the fields of the form and the client only a message with the $Body defined in the CMS, for example saying ‘Form received, thanks!’.

    Hope it helps,
    Juan

  • Juanitou
    Avatar
    Community Member
    323 Posts

    Re: UserForms 0.2 Link to this post

    By the way, willr, when we could use complex values in template controls? I had to do all this ForAdmin trick because I cannot simply put something as:

    <% if To = admin@mysite.com %>

    The @ breaks the parser. Also, I have to use, for field values, the kind of ‘--choissisez--’ (‘--choose--’), all in ASCII, instead of a word or several of them containing ‘special’ chars as é, ç or ñ, or even an space.

    Well, that's not the fault of userforms…

    Best regards,
    Juan

    27173 Views
Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
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.