Unpredictable placement order of Fields for a Form

Topics: Administration, Core, General
Nov 20, 2012 at 9:42 PM

I went to create a new form in Orchard (using the Forms module) and created a custom Type to do so, after I finished entering all the fields I noticed that the order I created them was disregarded and instead it appeared to be using a combination of Field Type and maybe alphabetical (I didn't look closely at the time but noticed this later on). At the time I figured it was annoying but Forms is relatively new to Orchard, so then I went to try reordering them using the Edit Placement button. However after going through the 30+ some odd fields on this form and saving it, the order they actually ended up in don't reflect what I set them to. I tried to setup the correct order again, hit save and they are in a different order still. I took a look at the HTML on the Edit Placement page for this custom type and noticed it's using a position data attribute on each LI and it appears because of the multiple attempts of editing the placement to get the right order I have some fields that are 6 numbers deep (ex. Any help in this regard would be greatly appreciated.

Nov 21, 2012 at 1:27 AM
Edited Nov 21, 2012 at 1:30 AM

I don't know if this is what you are after, but check out RobertTheGrey's writeup. It's using the new CustomForms module in Orchard. About midway down the page he's got a section on Placement.

Other than that, you could modify the Placement file.

BTW, 30+ fields on one page? Or are you using a wizard?

Nov 28, 2012 at 8:47 PM

Currently it's all on one page, though I didn't know orchard supported anything along the lines of a wizard?. The client wants to use it as a signup form/questionnaire for the general public to use (the submitted form will be sent via email). I have seen that post but the client will be the one maintaining the questions and expecting them to manually download an XML file, modify it, and re-upload it to the server with out making a mistake resulting in a support call every time is not realistic. The built in Placement screen serves this purpose but it's also unreliable as I mentioned above. I'm pretty sure it's a glitch in the code as I can't see if being of any use to anyone the way it is.

Nov 28, 2012 at 9:01 PM

Placement is pretty difficult when you are getting down to I noticed this in the Admin with Widgets (aside from coding a Placement file), where I would try to reorder widgets and it got screwy.

Orchard itself does not have a wizard, but you can code an MVC one. After a lot of trial and error and help from the community here and on SO, I got one working pretty well. I am not relying on CustomForms. I rolled my own module. I am able to save user input in the Admin for viewing.

With respect to the XML file you mentioned, I don't recall that being part of the process of creating a CustomForm.

Nov 29, 2012 at 3:10 PM

No, I mean to say the only two ways I know of to order the questions on the form is through the Edit Placement link onm the page (which is what it unreliable currently because of the crazy depth it uses when doing many changes) and the placement XML file. The UI method is preferable but that doesn't work, and the XML placement file is not something I want to expose to the end user. It the Edit Placement needs that level of depth for ordering (1, 2, 2.5, 2.5.5, 2.7, 3.0, 3.5, 3.5.6, 4.0, etc.) It'd be nice if it was implemented with a UI interface similar to the Navigation page where you can indent pages to show their nesting inside of a parent.

Nov 29, 2012 at 5:51 PM

The right thing to do might be to fix the admin placement feature and then submit a pull request.

Nov 29, 2012 at 5:53 PM
Edited Nov 29, 2012 at 5:54 PM

Got it.

I don't think you are going to have much luck with your current method. Even if the UI Placement for the form worked, your users have access to it and will likely muck it up. I can't see too many business use cases for continually changing forms by the user themselves - it's fraught with danger in that invariably if they don't know the system they may cause more problems (and more calls to you). Unless you can train an admin for them, I don't see a way around that.

It sounds like they'd be better off getting you to create the forms in a module. I can't see using CustomForms for anything but the most basic of forms. 30+ fields, while doable by that module, doesn't sound doable if you are leaving things up to your users.

Mock up a wizard for them in a module and show it off to them. Maybe they'll want that instead?

Otherwise, @bertrandleroy's suggestion.