1
m0nty
XoopsFormTextDateSelect problem
  • 2005/6/20 0:39

  • m0nty

  • XOOPS is my life!

  • Posts: 3337

  • Since: 2003/10/24


i'm trying to add a date of birth field to userinfo..

all is well so far and i have the date function working on submission..

using this line in edituser.php

$birth_text = new XoopsFormTextDateSelect(_US_BIRTH"user_birth"1010$xoopsUser->getVar("user_birth""E"));


this works fine, i also had to modify include/calendarjs.php to change the minimum date from 2000 to 1900 which now allows a user to select all dates from 1900 - 2015

however for some reason, when i click to edit my profile again, it doesn't retrieve the value for the date i previously submitted..

it is correct in the databse, using DATE type for the table row.

but instead of showing my submitted date, it always puts a default date of '1969-12-31'

which means whenever i update my profile again, i always have to keep updating the date of birth.

is there anyway round this? i've been trying for hrs to figure out why.

2
m0nty
Re: XoopsFormTextDateSelect problem
  • 2005/6/20 5:58

  • m0nty

  • XOOPS is my life!

  • Posts: 3337

  • Since: 2003/10/24


ok have kind of got round that problem by creating a new form class

XoopsFormTextDateOfBirth

altho the same problem exists, except i edited the formclass and set the value to '' instead.. this gives a clear text box, which is handy for the registration form.

but i still need to retrieve the value for edituser.php

altho i'm trying to add a small if statement to the form..

what i want is the date of birth field to only be able to be edited once by the user.. they have to set it on registration and that works fine.. but for existing users that are there before i apply the hack means they will not have a current date of birth set.. so i need it to allow editing once.. once it has been set then they can't edit it again (only admin can via admin panel)

here's what i have so far but i can't get it to work right..

mysql date format defaults to 0000-00-00 which is the value of an empty field.

in edituser.php

if ($xoopsUser->getVar("user_birth") = '0000-00-00') {
    
$birth_text = new XoopsFormLabel(_US_BIRTH$xoopsUser->getVar("user_birth"));
    }
    else {
    
$birth_text = new XoopsFormTextDateOfBirth(_US_BIRTH"user_birth"1010$xoopsUser->getVar("user_birth""E"));
    }


i'm not sure i've done it the right way, well i know i haven't or it would have worked. but i can't seem to get the current users date value from the db. i've tried lots of different methods :S

3
Mithrandir
Re: XoopsFormTextDateSelect problem

I believe the problem stems from the fact that the calendar script expects a UNIX timestamp as the value. UNIX timestamps only go from 1/1-1970 to sometime in 2038.

I guess the best solution would be to make a XoopsForm element that does not use the calendar (or change the calendar to not use a UNIX timestamp... but that does not seem simple) but instead have drop-downs for year-month-day (perhaps multiple elements with year, year & month, year & month & day?)

4
m0nty
Re: XoopsFormTextDateSelect problem
  • 2005/6/20 10:54

  • m0nty

  • XOOPS is my life!

  • Posts: 3337

  • Since: 2003/10/24


ok thanks mith, seems this dob selection isn't as simple as it could be.

i originally thought of creating 3 new form select elements, day, month and year.. but like the text input method of using yyyy-mm-dd even that's not so straightforward as somewhere along the line a format check would be required to check the correct date format..

can't have people saying there's 31 days in february or 31 days in june etc.. i'll figure somethin out eventually if i keep at it long enough :)

Login

Who's Online

491 user(s) are online (50 user(s) are browsing Support Forums)


Members: 0


Guests: 491


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Sep 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits