Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unselected Year/Month/Day not working in {html_select_date} #395

Closed
bluepowder opened this issue Oct 16, 2017 · 2 comments
Closed

Unselected Year/Month/Day not working in {html_select_date} #395

bluepowder opened this issue Oct 16, 2017 · 2 comments

Comments

@bluepowder
Copy link

bluepowder commented Oct 16, 2017

Using the latest master from GitHub (or the 3.1.30 release), it is not possible to have an unselected Year/Month/Day, as described in the documentation (see below). Attempting to use "2015-08-" as a time value (for example) defaults to the current date.

On:
https://www.smarty.net/docs/en/language.function.html.select.date.tpl

year_empty -> "use values like “-MM-DD” as time-attribute to indicate an unselected year"
month_empty -> "use values like “YYYY--DD” as time-attribute to indicate an unselected month"
day_empty -> "use values like “YYYY-MM-” as time-attribute to indicate an unselected day"

@bluepowder bluepowder changed the title Unselected Year/Month/Day not supported as described in docs Unselected Year/Month/Day not working in {html_select_date} Oct 17, 2017
@bluepowder
Copy link
Author

bluepowder commented Oct 21, 2017

After further examining the documentation & code ( https://github.com/smarty-php/smarty/blob/master/libs/plugins/function.html_select_date.php ) - and not finding any examples of using arrays for $time - I was able to make this work using an array. The original issue still exists - "1997--", etc does not work.

Here's how the array works:

$date_x = "2005-00-00"; //For when I needed just a year, no month or day
$date_y = explode('-', $date_x);

// "Date_" is the default prefix
$date_z = [
    'Date_Year' => ($date_y[0] > 0 ? $date_y[0] : 'null'),
    'Date_Month' => ($date_y[1] > 0 ? $date_y[1] : 'null'),
    'Date_Day' => ($date_y[2] > 0 ? $date_y[2] : 'null')
];

$smarty->assign('time', $date_z);

@wisskid
Copy link
Contributor

wisskid commented Feb 6, 2020

@bluepowder is correct this not doing what it should do according to de docs
A fix would not be too hard and I don't see how it could mess anything up unintentionally.
Alternatively, since there is a workaround with an array, we could also just fix the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants