Gossamer Forum
Quote Reply
Date Input Dropdowns
Heya all,

I have a couple of date fields set to the standard YYYY-MM-DD format.

On the user end I'd like to provide users with three dropdowns to enter a date: the first with days 1-31, second with January-December and the third with a few years, say this year and the next 3. I don't mind if the form has to be set up manually but generating it automatically would be nice. Wink

How can I take the input from a form like this and save it in a field in the DB (when the rest of the link is submitted) in the standard format above?

Safe swoops
Sangiro
Quote Reply
Re: [sangiro] Date Input Dropdowns In reply to
Bueller, Bueller? Anyone?

Safe swoops
Sangiro
Quote Reply
Re: [sangiro] Date Input Dropdowns In reply to
You should be able to do it by adding a day, month and year field to your database; as well as a Date_Joined field. Then, in /Links/Users/Add.pm, you need to find the part where the final field values are set, and add something like;

$link->{Date_Joined} = $IN->param('year') . "-" . $IN->param('month') . "-" $IN->param('day');

Hope that helps.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Date Input Dropdowns In reply to
I think I did this in the postcards plugin, but it was script based.

Might be something to consider moving to the SQL Widgets area. Could probably be done with a tiny plugin that had a join_date and split_date function that would be called on the various submit hooks. You'd trigger it with a form tag that would pick off the fields. You could use multiple such fields by passing in html_form_date_join_1 = added_date , html_form_date_join_2 = expire_date, then pick off the tags expire_date_day, expire_date_month and expire_date_year and pass them back as

expire_date = expire_date_year . '-' . expire_date_month . '-' . expire_date_day

The tag beginning with html_form_date_join (or split) would trigger the function to go look for fields with the name-value stored in that tag, and append the _day, _month, _year to yank or set values.

This would allow a purely template-based model for joining/splitting dates in a form.

Just some thoughts....


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] Date Input Dropdowns In reply to
Indeed, it would be pretty simple to write. Just add in a hook for user_add_link, user_modify_link, modify_link and add_link; so that they slice up the pre-defined field(s), and put their seperate values into another field.

Although its pretty simple to do, its just finding the time :(

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Date Input Dropdowns In reply to
Yup - It could also be used to solve the problem I discussed in this thread. It may be a bit different from dates but being able to slice of the actual category would be useful as well.

Example: Category = Region/Country/State/

When a user selects to place a link in that category it would be great to also split up the category name and save the Region, Country and State values in their own fields in the links table. That way they can simple be called as a tag from all the links templates.

I'm trying to do some geomapping (calculating distances between points) against my db and are running into the problem that the country and state for each link, which is pretty crucial for mapping) sits in the category table and not with the rest of the link info... Frown

Safe swoops
Sangiro

Last edited by:

sangiro: Aug 2, 2004, 10:05 AM