Form layout for inputting data
Hi Chris,
Many thanks for the terrific video series on Drupal 7 - your excellent videos are simply the best source of training and information on Drupal in existence!
I have a question concerning form layout for inputting data into Drupal. For output, modules such as Views and Display Suite are fantastic, but what about input? If I have forms or nodes that have numerous fields, what is the best approach to arranging these fields for the editing mode? Do I have to manually create templates for this mode or are there modules out there that will assist in this task? Not sure what the best practices would be, so any suggestions would be most welcome - or of course, a video on this topic :)
Thanks,
Ken
Hi Ken!
This is a great question, and one that I've gotten a few times. As far as I know (but I'd love to hear if other folks have heard of something) there's not a module specifically geared toward modifying form layout, though I could see that being an interesting project since it's kind of a bugger getting a form to look just right.
There are a lot of things you can do with CSS and simple markup within the form, using #prefix, #suffix and markup element types. If you're dealing with an existing form, you can get access to all of these things with hook_form_alter().
If you need to do more intense manipulation (like looping through inputs), then you'll probably use a form's theme function to do the work. You can then render specific inputs within easier-to-manipulate blocks of HTML, rather than fragmented HTML that you'd put in #prefix and #suffix.
Let me know if that points you in the right direction.
Cheers!
Chris