Recommend this page to a friend! |
|
![]() Manuel,
I'm trying to use the form_date_class for the first time along with Smarty but facing some issues. I get invalid input 'p_date_year', 'p_date_month' etc errors and the input would not render in the page except for the ' / / ' separators. I've also tried adding the code from test_date_input.php to the test_smarty_form.php as under but the page comes out blank: require("form_date.php"); $day_seconds=60*60*24; $start_date=strftime("%Y-%m-%d",time()+1*$day_seconds); $end_date=strftime("%Y-%m-%d",time()+7*$day_seconds); $form->AddInput(array( "TYPE"=>"custom", "ID"=>"date", "LABEL"=>"<u>D</u>ate", "ACCESSKEY"=>"D", "CustomClass"=>"form_date_class", "VALUE"=>strftime("%Y-%m-%d"), "Format"=>"{day}/{month}/{year}", "Months"=>array( "01"=>"January", "02"=>"February", "03"=>"March", "04"=>"April", "05"=>"May", "06"=>"June", "07"=>"July", "08"=>"August", "09"=>"September", "10"=>"October", "11"=>"November", "12"=>"December" ), "Optional"=>1, "ValidationStartDate"=>$start_date, "ValidationStartDateErrorMessage"=>"It was specified a schedule date before the start date.", "ValidationEndDate"=>$end_date, "ValidationEndDateErrorMessage"=>"It was specified a schedule date after the end date.", )); FORM.TPL -------- <tr> <th align="right">{label for="date"}:</th> <td>{input name="date"}</td> <td>{$mark}</td> {/if} </tr> I've also tried using inputs names such as p_date_year, p_date_month, etc. but in vain :( Please help... TIA
![]() I'm using this to ask for user's birthdays. Users need to be 18 years old at least.
//user_registration_form.php require("forms.php"); require("form_date.php"); ... $months = array( "01"=>"January", "02"=>"February", "03"=>"March", "04"=>"April", "05"=>"May", "06"=>"June", "07"=>"July", "08"=>"August", "09"=>"September", "10"=>"October", "11"=>"November", "12"=>"December" ); $dateStart = mktime(0, 0, 0, date("m"), date("d"), date("Y")-99); $dateStop = mktime(0, 0, 0, date("m"), date("d"), date("Y")-18); $start_date = strftime("%Y-%m-%d",$dateStart); $end_date = strftime("%Y-%m-%d",$dateStop); $form->AddInput(array( "TYPE" => "custom", "ID" => "Birthday", "LABEL" => "Birthday", "LabelCLASS" => "Labels", "LabelID" => "LabelBirthday", "LabelTITLE" => "Please tell us when you were born.", "CustomClass" => "form_date_class", "VALUE" => strftime("%Y-%m-%d",$dateStop+(60*60*24)), "Format" => "{day}{month}{year}", "Months" => $months, "Optional" => false, "SelectYears" => 100, "TABINDEX" => 3, "TITLE" => "Please tell us when you were born.", "ValidationStartDate" => $start_date, "ValidationStartDateErrorMessage" => "Sorry, you are way too old!", "ValidationEndDate" => $end_date, "ValidationEndDateErrorMessage" => "Sorry, you are too young!", )); ... //user_registration_template.php ... <tr> <td class="LabelsTD"> <?php $form->AddLabelPart(array("FOR"=>"Birthday")); echo "\n"; ?> </td> <td class="InputsTD"> <?php $form->AddInputPart("Birthday"); echo "\n"; ?> </td> </tr> ... The VALUE-string is set to the birthday of people who are getting 18 tomorrow. Meaning that if today would be the 12.03.2007, the 3 select-fields would show "13" "March" "1989". This way people need to set a specific date which validate their age. What I miss in your code is the "SelectYears"-string. And in my example all of this is not optional, as in your example. Note the opposite of the ValidationStart- and ValidationEndDateErrorMessage!!! And the ValidationStartDate can be ommited in my code, but I found it funny to keep. This works perfectly. I'm just not working with Smarty... But looking over your code, {/if} seems to be an ending tag for something, there surely need to be something like a start-tag? As said, I haven't used Smarty yet... And if this is a stupid and unqualified answer, blame me... but not too hard! :-) Tarak P.S.: I'm not using this for adult-content-things, so please...
![]() Another thing I'm thinking about: You have addressed your question to Mr. Lemos himself... I don't want to criticise you, but I think that Manuel should not be the only one answering questions here. This seems like a huge community to me. So others should answer too, if they can. I think that Manuel is as busy as all of us. As said, I don't want to criticise anyone...
Tarak
![]() Hi,
Thanks for the reply. That did not help. Here is my input: $months = array( "01"=>"January", "02"=>"February", "03"=>"March", "04"=>"April", "05"=>"May", "06"=>"June", "07"=>"July", "08"=>"August", "09"=>"September", "10"=>"October", "11"=>"November", "12"=>"December" ); $input = array( 'ID' => 'Date', 'TYPE' => 'custom', 'CustomClass' => 'form_date_class', 'VALUE' => strftime("%Y-%m-%d"), 'SelectYears' => 100, 'Optional'=> 1, 'Months' = $months, "Format" => "{day}{month}{year}"); And here are the errors I'm getting on submitting the form: p_Date_year_year: it was not specified a valid input p_Date_year_month: it was not specified a valid input p_Date_year_day: it was not specified a valid input p_Date_year_hour: it was not specified a valid input p_Date_year_minute: it was not specified a valid input p_Date_year_second: it was not specified a valid input p_Date_month_year: it was not specified a valid input p_Date_month_month: it was not specified a valid input p_Date_month_day: it was not specified a valid input p_Date_month_hour: it was not specified a valid input p_Date_month_minute: it was not specified a valid input p_Date_month_second: it was not specified a valid input p_Date_day_year: it was not specified a valid input p_Date_day_month: it was not specified a valid input p_Date_day_day: it was not specified a valid input p_Date_day_hour: it was not specified a valid input p_Date_day_minute: it was not specified a valid input p_Date_day_second: it was not specified a valid input Strangely, on inspecting the HTML source, I found the inputs are actually generated but but with HIDDEN visibility for some reason! On submitting the form, the GET url reads like so: p_Date_day=&p_Date_month=&p_Date_year=&p_Date_year=&p_Date_month=&p_Date_day= Are the inputs supposed to generate with a suffix and also a prefix? I don't understand what those year_year, year_month, year_day, month_year, month_month, month_day, etc. are. Regards,
![]() I added an:
'ExtraAttributes' => array( 'visibility' => 'visible' ) to the input and now I get the custom input rendered on the form. I apologize I had duplicated inputs in my template that rendered two sets of inputs earlier. But I'm still trying to figure out why the inputs are rendered as hidden. Thanks,
![]() Never mind! I nailed down the bug in my code. I knew it was a glitch with my code.
Regards,
![]() I could not reproduce that problem. Maybe if you can provide a complete script I can see what is going on.
![]() Manuel,
It was a glitch in my form_class extension that was setting the invisible attribute on another input-type that was also getting applied to date class custom input. I just posted this message desparately. |
info at phpclasses dot org
.