Placement / Viewing Problem with Custom Form Widget

Topics: General, Troubleshooting
Nov 7, 2013 at 5:55 PM
Edited Nov 11, 2013 at 1:35 PM
Not sure if I messed something up, but am scratching my head.

I created a Custom Form (Type plus Widget on a Page).

I created alternates so that I might have some more control over the display of the form. Created:

~/Views/Parts.CustomForm.Wrapper-url-path1-path2.cshtml
~/Views/Content.Edit-MyForm.cshtml

These were created under a sub-theme using Shape Tracing.

The Wrapper was created to have some text over the submit button - deleting it so that the normal Wrapper is used had no effect on my problem.

Content.Edit-MyForm.cshmtl has something like this:
<div class="edit-item">
    <div class="edit-item-primary">
        @if (Model.Content != null)
        {
            <div class="edit-item-content">
                <div class="page-sub-title">
                    <h1>Basic Information</h1>
                </div>
                <p>
                    Please tell us about yourself. <strong>Your personal information will remain strictly confidential.</strong>
                </p>
                <div class="one-half">
                    @Display(Model.FirstName)
                </div>
                <div class="one-half last">
                    @Display(Model.LastName)
                </div>
                ...
                <div class="page-sub-title">
                    <h1>Personal Information</h1>
                </div>
                ... <!--REST OF FORM-->
            </div>
        }
    </div>
</div>

@if (!String.IsNullOrWhiteSpace(Request.QueryString["returnUrl"]))
{
    @Html.Hidden("returnUrl", Request.QueryString["returnUrl"])
}
Here is a sample of the placement:
<Match ContentType="MyForm">
        <Place Fields_Input_Edit-FirstName="FirstName:1"/>
        <Place Fields_Input_Edit-LastName="LastName:1"/>
        // REST OF FIELDS
</Match>
This works fine when I am logged in as the Admin. I can view the form the way I laid it out.

However, if I sign out, then I can only see my custom form wrapper (with the text above the submit button). Shape tracing shows that the template contains what the Content.Edit file has.

Now, I did check off the Anonymous permission for "Submit My Form".

Still not clear why I cannot see the form if I am not logged in. I suspect it's placement but I am horrible with writing placements.

Any thoughts?
Nov 8, 2013 at 4:56 PM
Edited Nov 8, 2013 at 5:03 PM
Custom Forms has a lot of potential. Unfortunately, I cannot seem to tap that potential. I know that this is a community effort, but my abilities in this regard are limited (i.e., I cannot program the changes that I think would be useful to everyone - my programming skills are at best intermediate). The alternative for me is to figure out ways around my limits, and to that end I was trying to come up with a way to "style" a custom form. My ultimate goal was to add this information to the documentation on creating a Custom Form as an addendum.

What I was able to come up with is along the lines of the code I displayed above: create an alternate for a form and then style it as I wish. I have hit a wall, however, because it seems that by modifying the way that Custom Forms displays the form (by using a customized placement mechanism) I have closed off the ability for anonymous users to see the form. Using the above placement, I noticed that when you go into the Content Type for the form and click on "Edit Placement" that the fields are not present. Comment out the placement I created and they do appear in that screen.

Is it possible that by creating this placement mechanism (in conjunction with the alternate form I created) I have circumvented the ability for anonymous users to view the form EVEN THOUGH the anonymous permission for "Submit Form: My Form" has been checked off in Users > Anonymous > Edit Role? I'm thinking this is the case. It may also be that the way I've chosen to style the form is incorrect, and that there is some other method of achieving what I want (maybe I am using incorrect alternates?)

I looked into adding some code either in the alternate ~/Views/Parts.CustomForm.Wrapper-url-path1-path2.cshtml or ~/Views/Content.Edit-MyForm.cshtml files I created in my theme in order to grant that permission, but I don't a) know if that's the correct way or b) know how to code it properly.

Two asides: First, yes, I can create (and have created) my own modules to have full control over forms. But in certain instances this is a bit overkill, particularly when you a) want to roll something fast and b) don't need all the bells and whistles when there is a mechanism in place (i.e., when I created a module to do this it was because I wanted to do stuff with the user inputs beyond the form and storage of user input, etc.).

Second, I know that CSS can be used to customize the form. However, CSS has its limits. For example, I cannot add text around the forms without creating an alternate or place "headers" around groups of fields in the form to give it a more consistent flow or just group common fields.
Nov 8, 2013 at 10:52 PM
Edited Nov 10, 2013 at 7:33 PM
Alright, after almost 6 hours sans the small amount of time I took to eat a sandwich and smoke a cigarette or two, I may have found a bug. I might be wrong, but don't want to unnecessarily inundate Sebastien with more issues ;). If it might be a bug just say so and I'll pop an issue. I think that a placement for an Enumeration Field that is a checkbox destroys placement for the other fields in a custom form under certain circumstances. Placement works with Enumeration Fields that are radio buttons and dropdowns.

Here's a rundown:
  1. I thought I might have to do Input_Edit-FirstName and Input-FirstName in placement. But I didn't do that for the other 15 fields (including Input_Edit-LastName) and didn't comment them out just to see if that one field will display. It doesn't work.
  2. I comment out those other 15 fields and leave both FirstName's, I now see the field when logged out (anonymous).
  3. I make this change (two <Place> elements for one field) for a few more fields and it works, I am able to see the fields on the page. Except that when I go back to the placement file I realized that I didn't create two <Place> elements for one field and it still displayed on the page. I figured out that it was one of the field types.
  4. Since I only had one checkbox field I commented it out and I was able to see all the other fields on the page. I had several radio button lists and dropdowns as other fields, and none of them were the problem. Each of the enumerations looked like this <Place Fields_Enumeration_Edit-MyField="MyField:1"/>, sending it to an ad-hoc zone thusly: Display(Model.MyField). I was able to view the checkbox list when I was logged in using Enumeration_Edit, but when I was anonymous I could not see any of the fields. And when I used <Place Fields_Enumeration-MyCheckBox="MyCheckBox:1"/> I could see all the other fields except the checkbox, which won't display.
I didn't see anywhere that the checkboxes were to be described differently in the <Place> file.
Dec 3, 2013 at 5:03 PM
Cross-posted here: StackOverflow