Login Retreive lost passwordRegister
Search

Forum Index / General / Adding a Custom Built Field

[ This topic is solved ]

  bigAPE 19 July 05 / 15:05  
Hi Guys,

My apologies if this is covered in the manual, I fear it probably isn't.

I want to be be able to use the OPTGROUP element in a SELECT field.


<select name=sections>
  <optgroup label="Film & Photography">
    <option value="1">Urban Rural</option>
    <option value="2">Portraits and People</option>
    <option value="3">Photo Journalism</option>
    <option value="4">Sports</option>
  </optgroup>
  <optgroup label="Crafts">
    <option value="5">Metal Work</option>
    <option value="6">Pottery</option>
    <option value="7">Woodwork</option>
    <option value="8">Model Making</option>
    <option value="9">Installation</option>
  </optgroup>
  <optgroup label="Fine Arts">
    <option value="10">Abstract</option>
    <option value="11">Portrait and Life</option>
    <option value="12">Landscape</option>
    <option value="13">Installation</option>
  </optgroup>
</select>


I have written the code to generate the result set from a SQL call to a hierarchical table which then uses a dynamically loaded constants-based language file to translate the "codename" for the sections/sub-sections. I have then written a routine which checks when the Section changes and wraps that group in an optgroup element. All simple stuff.

However, I want to be able to include this custom INPUT element as part of a FormHandler form. Is there any way that this can be done like adding it as Custom HTML.

On a successful form result the form values are loaded into a Transfer object and passed in the Business tier, so these Forms don't need write to a database or anything.

Any help gratefully welcomed,

bigAPE

  Teye Heimans (Founder) 19 July 05 / 15:33  
Did you take a look at the selectfield page in the manual? There is explained how to use OPTGROUP. (See the example!)

  bigAPE 19 July 05 / 16:08  
DOH! Your right of course, sorry about that. I was in full-on "try first, RTFM later" mode. I will try to alter the array to fit your format

After some play it is also possible to genererate the field as raw HTML and include it using AddHTML(). Then using POST to return the value in your onCorrect event handler.

  bigAPE 19 July 05 / 16:56  
All working now, thanks for the pointer.

  Teye Heimans (Founder) 19 July 05 / 17:08  
no problem ;-)

  sassiewas 16 August 10 / 13:39  
Okay, this i understand.
But what to do when your selectField is generated from a DB?
Then you can't add the __LABEL__ to the output.

Or is this a really dumb question?

  Johan Wiegel (Admin) 16 August 10 / 14:14  
Shouldn't be a problem,

when you put the options form the database in an array you can add opt groups where ever you want.

  Top


powered by PHP-GLOBE   © 2004 - 2012 FormHandler. All rights reserved.   -   Open source license