When label elements are added that are appended with a colon which is often not required or is undesireable. Could we turn of the automatic colon addition for labels allowing the user to designate the entire label.

Where this is most problematic where you might wish to use say: <h3>Section Heading</h3><HR> as a label. You end up with this:

Section Heading



---------------------------------------------------------------------------------------

:

Note the colon below the horizontal rule, it looks a bit ugly.

Alternatively, you could make the appended character (currently a colon), a settable field in the module settings so that people like me could set it to null and then we would be responsible for putting colons on all of our other field names as required. This approach would admittedly lose flexibility in subsequent reporting because all our field names would have a colon as part of the name string.

CommentFileSizeAuthor
#2 webform_fieldsetmockup.png34.24 KBullgren
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Anonymous’s picture

ullgren’s picture

Assigned: Unassigned » ullgren
FileSize
34.24 KB

The colon is added by the Drupal framework as part of form_item()

I have had some ideas about fromating a label as a fieldset instead (see the mockup image).
Is this a better idea ?

Anonymous’s picture

Yes,

that looks excellent, the questions are blocked with a block heading and I believe I can see one label "Questions about OS related skills".

Is this in cvs?

jnt

ullgren’s picture

There is two labels in this form "Operating systems" and "Hardware".
The first one has it's Description field set to: "Questions about OS related skills"

This is only a mockup as in made from scratch in vi, So no code is in place yet.
This new behaviour of label would suite my needs but I just wanted to know how my users (you) work with the component. Maybe I should leave "label" as it is and add a new form component named something like "group label" ?

jnt’s picture

I would vote for the two seperate label types:

  1. Group Heading
  2. Label

This is intuitively less complicated and presumably easier to code.

I presume a 'Group Heading' would block to immediately preceeding the next 'Group Heading' or END_OF_FORM, whichever came first.

ullgren’s picture

Yes that was what I had in mind.
Since the : sign after the label is added by drupals theme_form_element function.
One way to get around your the original question is to override this function in your own theme.

yourtheme_form_element($title, $value, $description = NULL, $id = NULL, $required = FALSE, $error = FALSE) {

  $output  = "<div class=\"form-item\">\n";
  $required = $required ? theme('mark') : '';

  if ($title) {
    if ($id) {
      $output .= " <label for=\"$id\">$title</label>$required<br />\n";
    }
    else {
      $output .= " <label>$title</label>$required<br />\n";
    }
  }

  $output .= " $value\n";

  if ($description) {
    $output .= " <div class=\"description\">$description</div>\n";
  }

  $output .= "</div>\n";

  return $output;
}

I don't know if there is a way to get the node type from inside this function. A quick and dirty way would be to set a global variable in your theme _page() and then check that variable in the _form_element().

jnt’s picture

It is sometimes desirable to have a block of text that can give explaination or instructions to the following section. This would be an uneditable block of text simply presented but weighted as per other components. I therefore request that the "Group Heading" as discussed in this thread be given this functionality.

The administrative user when adding a Group Heading would be given a text field to allow them to enter text as apprpriate. The text area could be left blank thus leaving the group heading (or block start) by itself

Marc Bijl’s picture

Hi, I was just very curious about the status of this issue.

At one of my sites, users can request (send an email) for three different packages. For each package they need to fill in different fields. Right now, I'm at the decision making of using:

- 1 form (with 3 clearly separated groups of fields)
- 3 separate forms (with required fields per form)

If I choose for the first solution, I stumble upon the same problems as jnt (isssues initiator) when customizing the look of a label. Therefore Ullgruns idea #2 looks more than excellent to me: very, very neat solution!

However, does anyone know the status of this issue? Moreover, does anyone know how I can work around this and get a solution with the look of Ullgruns image/attachment?

Looking forward to replies!

Marc

pepeek’s picture

Title: Label charecteristics » Progres?

Hate to be pushy, but this feature is really a killer one ;-)
Any progres so far, or at least an est?

quicksketch’s picture

I've been looking into how to implement this feature, though I haven't yet begun to write any code. I'm pondering how to implement the arrangement of fields into the fieldsets. Here's how I'm imagining this so far.

  • Create a fieldset like any other component
  • As you modify each component, you are able to choose a 'parent' component, which would only list available fieldsets

I guess that's it. Seems like I had more complicated plans before... Anyone that has input, please let me know.

ullgren’s picture

Title: Progres? » Label charecteristics

Thats a great solution.
My original idea was to create a group/lable component and then use weight to decide when and where to break to the next lable.

lennart’s picture

quicksketch, that sounds like a great solution - basically like the book outline function, where you can decide where a page should go in the hierarchy. Yo can choose a parent for the child.

BachusII’s picture

I am in need of such functionality (fieldsets) myself.
Rather than doing it completely on my own, is there some way I can be of assistence coding?

quicksketch’s picture

Title: Label charecteristics » Seperate fields into fieldsets
Assigned: ullgren » quicksketch

Demand for this feature seems to be steadily increasing. I'm taking it up this weekend.

quicksketch’s picture

I posted a new module to CVS today, along with new required dependent files (webform.inc, webform.install, and fieldset.inc). The CVS archive should be created shortly with the new files. I encourage anyone interested in this feature to post feedback and suggestions. Please make a backup of your database as this revision makes a change in the database schema. Of course, this change also means you'll need to run update.php after updating the module.

quicksketch’s picture

Status: Active » Closed (fixed)

Marking as closed. Will soon merge with 4.7 branch.