Some autocomplete widgets allow you to clear the hidden field when the
text field has not been selected from the dropdown.  I think YUI
allows that which kind of alleviates this problem because if they
delete part of the input text then it clears the hidden field.

If you still need to pass it through I think you should extend a
FormValidator, which is pretty much just a FancyValidator I guess, and
put it in chained_validators since it must apply to two fields.  Then
you can perform the lookup within the validator to compare the
database name with the submitted name.  When you put a validator in
chained_validators I think the usual value argument becomes a
dictionary of all the fields.

I'm not sure what everyone else is doing but this is how I make
chained validators.  Here is an example of a validator for a username
and password, get_user_info is a function that accesses the database.
It is more complicated than necessary but you should be able to see
how it works. Note that errors['form'] is meant for the whole form, if
you want the error to be next to your specific field you should set
the correct field name in the errors dictionary.

http://pylonshq.com/pasties/c585b5797c372ddd7500973fce67e969


On Feb 28, 8:00 pm, Mark <[email protected]> wrote:
> Hi experts and gurus,
>
> I have a class registration form with a location field.  I designed
> the location field like the select/input box found in Google Reader at
> the top.  The user is both able to enter some value at the same time
> is also able to select from a list of values.  I used CSS to position
> the input field on top of the select box (with the drop down arrow
> showing).
>
> Anyways, I also have a hidden field with the name location_id.  When
> user enters something, and selects something from the autocomplete or
> just selects something from the drop down, the hidden field value
> attribute is populated using javascript.
>
> The location_id is passed to the server for processing.  I need to
> check if the location_id's corresponding location_name (from the
> database) is exactly what the user typed in the text field (because
> although there is autocomplete, the user may still delete one or two
> characters in the input field).
>
> I too have another field called organizer, that upon submission sends
> the hidden field value:
>
> <label for="organizer" id="organizer_id_label">Organizer<em>*</em></
> label>
> <input type="text" name="organizer" id="organizer" value="$
> {c.organizer_init}"/>
> <input type="hidden" name="organizer_id" id="organizer_id" value="$
> {c.organizer_id_init}" />
>
> This is an autocomplete input field, so upon typing something and then
> SELECTING from the list of autocompleted values, the organizer_id
> hidden field is populated.  How do I validate whether the organizer_id
> is indeed corresponding to the name of the organizer in the text input
> field (supposing the user deleted 1 character in the input field)?
>
> FancyValidator for sure right?  But how do I retrieve values from both
> input fields for comparrison in the DB?
>
> -Mark

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to