Jump to:

10994 Posts in 2728 Topics by 1819 members

All other Modules

SilverStripe Forums » All other Modules » Change the look of UserDefinedForms

Discuss all other Modules here.

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

Page: 1 2
Go to End
Author Topic: 1963 Views
  • senica
    Avatar
    Community Member
    18 Posts

    Change the look of UserDefinedForms Link to this post

    Willr pointed me to using $Form to call my form from the UserDefinedForms module.

    Of course, my client wanted some things changed.

    I went digging for template to no avail.

    I did find in the forum how to call the different elements of the form which would have worked great except no <form> tag and no <submit> button to be found:

    I was using this:

    <% control Form %>
             <% control Fields %>
                <% if Type == textarea %>
                   <div style="overflow:hidden;">                  
                      <div class="formTitle">$Title &nbsp;&nbsp;$Message</div>
                      <div>$Field</div>
                   </div>
                <% else %>
                   <div style="overflow:hidden;">
                      <div class="formError">$Message</div>
                      <div style="float:left">$Field</div><div class="formTitle" style="float:left;">$Title</div>
                   </div>
                <% end_if %>
                $SubmitButton
             <% end_control %>
             <% end_control %>

    $SubmitButton or $Submit does not work.

    Is there a template being called when I use $Form that I can just edit? I tried to find what .php file is generating the code but just couldn't find it.

    In the end, I just need to change the way the form looks.

    Thanks!

  • TotalNet
    Avatar
    Community Member
    181 Posts

    Re: Change the look of UserDefinedForms Link to this post

    This can best be achieved with form.css - if you know the layout of the form then you can use the element ID to style each individual form field or otherwise just style them by element type or class.

  • senica
    Avatar
    Community Member
    18 Posts

    Re: Change the look of UserDefinedForms Link to this post

    Right, except that in my case, I need the form field Titles to come after the form field, which is a little harder to accomplish with css unless I use the left: attribute and swap them around. It will just get a little harry doing it that way. I'm looking at the API for Form() as it seems to follow that, but still not finding how to display the submit button yet...still loooking.

  • TotalNet
    Avatar
    Community Member
    181 Posts

    Re: Change the look of UserDefinedForms Link to this post

    In that case you can always add a "heading" after each form field which adds a label with a class of FormHeading then you can use css to hide the system generated labels.

    it's not a pretty solution but means you can avoid editing the core.

    Not sure what you're aiming for with the submit button.

  • senica
    Avatar
    Community Member
    18 Posts

    Re: Change the look of UserDefinedForms Link to this post

    Well, what I was talking about with the submit button was....if I use the code above, how do I display the submit button and the <form tag?

    I'm reading here: http://api.silverstripe.org/2.4/forms/core/Form.html#var$fields and looking at the Variables, but I just don't get it. And when I try stuff it doesn't work, or it may be that UserDefinedForms does not actually extend the Forms class.

    :sigh:

    using the Code above, I can almost rebuild the entire form, but I cannot figure out how to get the submit button to show...using what variable? ie $Submit and also the form tag? ie <form action="$action" method="$formMethod" $options>

  • TotalNet
    Avatar
    Community Member
    181 Posts

    Re: Change the look of UserDefinedForms Link to this post

    Never had that problem with USerDefinedForms, the submit button is always there and the text on it set by the user in the CMS.

    If you want complete control over the form layout and don't need/want the user to set it up with the CMS then tutorial 3 deals with writing forms.

    You should be able to use UDF to achieve your goals though without needing to touch any code or even template. Just set up the form in the CMS and use css to deal with layout and styling.

  • Willr
    Avatar
    Forum Moderator
    5508 Posts

    Re: Change the look of UserDefinedForms Link to this post

    Well you have <% control Fields %> that returns all the fields in the form. But what you want are the 'Actions' like the submit.

    <% control Actions %>
    ..
    <% end_control %>

    Use the default Form.ss as a guide for what you need to include http://open.silverstripe.org/browser/modules/sapphire/branches/2.4/templates/Includes/Form.ss

  • senica
    Avatar
    Community Member
    18 Posts

    Re: Change the look of UserDefinedForms Link to this post

    Willr,

    Why is that not in the documentation? I mean, in the API, under the Forms object, I saw the Actions() method, but there is no indications of what properties are available when you call it.

    Am I just suppose to guess until I get it right?

    Or am I just not reading the documentation correctly? http://api.silverstripe.org/2.4/forms/core/Form.html#methodActions

    1963 Views
Page: 1 2
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.