Forum OpenACS Development: doubleinput widget

Collapse
Posted by Malte Sussdorff on
Does anyone find this useful to have two input fields in one line? I am not sure if you can do this with the ZEN CSS (have all ad_form fields from top to bottom but one with two inputs).

ad_proc -public template::widget::doubleinput { type element_reference tag_attributes word } {

  upvar $element_reference element

  if { [info exists element(html)] } {
    array set attributes $element(html)
  }

  array set attributes $tag_attributes


  set output "<input type=\"$type\" name=\"$element(name).$word\" id=\"$element(name).$word\""

  foreach name [array names attributes] {
      append output " $name=\"$attributes($name)\""
  }



  append output " />"

  return $output
}

Collapse
2: Re: doubleinput widget (response to 1)
Posted by Emmanuelle Raffenne on
Malte,

Zen CSS won't complain about it and the element will be displayed as it has been built. However, the problem might be the validity of the resulting HTML. Each input field must be associated with a label -this is done in the label tag (&lt;label for="$the_input_id"&gt;)- and it's not possible to associate a label with 2 different input fields.

Collapse
3: Re: doubleinput widget (response to 2)
Posted by Malte Sussdorff on
Thanks for that information, that is useful, will forward that to the original developer. I think the label issue could be solved by having a "label for="${the_input_id}_1" and "_2". At least I have seen something like this in the date widget.

The question that remains for me is, should I commit this to core (HEAD)?

Collapse
4: Re: doubleinput widget (response to 3)
Posted by Gustaf Neumann on
malte,

where have you seen the &lt;label for=....&gt; with two ids?
Reading the HTML specs, this does not seem correct. I would think it would be correct to use a fieldset in such cases.

-gustaf

Collapse
5: Re: doubleinput widget (response to 4)
Posted by Carl Robert Blesius on
Malte, you can do this with CSS and html. No need for added complexity (especially if it introduces invalid html)

As part of the Zen work Mark spent some time testing example forms in all kinds of configurations using fieldsets and he was able to do magical things. I will see if he has those examples somewhere online. In the meantime google is your friend. E.g. a very quick search brought up this page which has two text inputs on the same line, where both the text inputs have a label (hidden via CSS). http://www.websemantics.co.uk/tutorials/accessible_forms/ (2.2 Simple Login)

Carl

Collapse
6: Re: doubleinput widget (response to 1)
Posted by Dave Bauer on
Carl,

I think the question is not how to put to form elements on one line with HTML, but how to do it with the tools provided by the formbuilder and ad_form.

Collapse
7: Re: doubleinput widget (response to 6)
Posted by Malte Sussdorff on
To be more precise, I want to have formbuilder with 5 elements, 3 of them are normal "text" which shall be shown one below the other. Number 4 and 5 shall be shown right next to each other (inline).

Note, I am not asking to have ALL elements inline, I am specifically asking for 2 inline, 3 normal and as Dave pointed out using ad_form without the need to write a custom /acs-templating/resources/forms/malte.adp

Gustaf, the code is something I found in a client's installation (not written by me), but I am bringing them up to 5.3 and assumed that whatever the doublewidget type does could be achieved with CSS and ad_form.

Collapse
8: Re: doubleinput widget (response to 7)
Posted by Emmanuelle Raffenne on
Malte,

There's no way to do what you need with the actual ad_form and formbuilder (AFAIK).

For that particular case and a quick solution, you can have a look at template::widget::date and do something similar.

About to add a doubleinput widget, I don't think it's the right way to go. Why double only? A triple one might be useful also (and would allow to rewrite the date one without using table for instance). I mean there's no reason for a fixed number of elements to display inline -however a limit would be necessary-.

Collapse
9: Re: doubleinput widget (response to 8)
Posted by Don Baccus on
It would be much better to fix the formbuilder than to put in a hack of this sort ...

Any takers?