1

I am using the agreservation module for a room reservation system/events calendar. As a result, the reservation content type has a large number of fields to accommodate info on speakers, contact info for participants, etc.

I have two uses for creating reservations: events, where more information is needed; and room reservations for maintenance issues, which require less info. However, having all of this info on one content type is essential: both uses require the room reservation and resource conflict functionality.

Restricting fields by role isn't an option as I have users who will need access to all fields; but when doing their work, both uses will be easier and quicker by having separate forms. It's more of a usability thing: people don't have to see fields they don't need for a particular use. Mainly, if someone needs to reserve a room for maintenance, the person making the reservation doesn't need to scroll through all of the fields for the event.

So, if a reservation node has fields a-j, how can I create separate node add forms so that fields a,b,c,d,e and f needed for creating registering an event are on one instance of the form and e,f,g,h,i and j are on another instance for the room reservation? There is overlap because the event involves the reservation of a room.

I thought about doing this via theming, but can a template be tied to a menu item?

0

You can use panels to create different a different views of the node add/edit forms. I've done something similar before but I had to add a query string to the URL and show the different view that I had setup. I will try to update with more information later.

Update with Instructions of how this can be done

Here is an overview of how I achieved this before. I used panels Panels and Context modules to set up this and show two different views for the node edit forms (Keep in mind your required fields will need to be present but this is just an overview of how you can achieve something like this.) First, some knowledge of both of these modules will be needed but you can learn as you go. First thing that I knew I needed was exactly what you said, two different node edit/add views where different fields showed at different times depending on the job being accomplished. I am going to run through a simple scenario that probably won't make much sense but it will show that it can be done with using these two powerful modules together.

First, I set up a context based on a query string. Go add a context in the context UI and add a condition based on query string. Then place your query string (mine is "view=maintenance") and not sure if you have to but I went ahead and added a body class by theme HTML in what the context does (you will see that in the context UI but you are going to really use this context in panels so just save it to use later).

Next go to Page manager and there is a page that you can use called Node Edit, you will need to turn this on and create your variant. You will want to choose node type in the context and restrict this to only the content type you want this to work with since it is specific to just that node edit form. For one of my views I wanted the whole form was needed. Use add content, Forms, and add general form. Now you have the form you had before just being controlled by panels. You will want to add a visibility rule and choose PHP code for the visibility rule. Then you can use the code below to find out if your context is present (Use Not if you want the full form to show without the query string).

$contexts_module = context_active_contexts();
if (array_key_exists('machine_name_of_context', $contexts_module)) {
  return TRUE;
}

So now you have the full form showing with or without the query string. At this point the form should not show on the other context. This is the only part that I don't really like but it works and its been the only way without writing a whole bunch of code that I have found can be flexible enough for others to change after I hand a site off to a client. You will have to add the fields that you want to show when the query string is present or not present (depending on what you chose earlier) and copy the code from above and either choose NOT or not choose NOT and also add the node submit buttons and choose that as well. (You of course can set each field up and hide the fields you want according to the query string or some other way, just play around with it until you learn it and understand what it can do).

I'm not really great at writing these instructions but hopefully you understood what it can do and how to do this. I will try to revise them over time to help future viewers. I am also including some screenshots below that will show this in action.

Context UI Query String setup Context UI Query String

Panel variant for clarity Panel Variant

This shows the whole form when the query string is present PHP code general form visibility

This is the not code, so when query string isn't present show this Not on node edit field

Shows url query string but (a partial screen shot) full form is shown to user URL showing query string on node/edit

Partial screen full form

Shows form trimmed down for normal use URL for regular node edit trimmed down form

Form trimmed down, shown b/c no query string is present

  • Excellent! Thanks for such a thorough explanation. Context is the one custom display module I hadn't messed around with. I'll have a go with this. – mattrweaver Jun 10 '15 at 16:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.