DT Plugin
ExpressionEngine 2, ExpressionEngine 3
Back to this add-on's main page
View Other Add-ons From Jerry Price
seting expiration date in channel form
Support Request
susanfw
|
Posted: 14 July 2016 05:53 PM |
|
|
|
I’m trying to set the expiration date in a channel form to be 3 months after the current date.
I’m using the EE3 version of the plugin and the following code:
<input type="hidden" name="expiration_date" value="{expiration_date}" value="{exp:dt set="{current_time}" month="3" format="%l %M %j, %Y"}">
But the expiration date is not being set. What do I have wrong?
Thanks
Susan
|
|
|
jjpmann
|
Posted: 14 July 2016 06:42 PM |
# 1
|
|
|
Hi Susan,
First check if the code is printing out the correct time in the format you want. Place this outside of the input tag to see if you can view it.
{exp:dt set="{current_time}" month="3" format="%l %M %j, %Y"}
Also I do notice you have two value attributes in the input tag and only one should be there. You can change the type to text and you should also be able to see the value in the field.
Jerry
|
|
|
susanfw
|
Posted: 14 July 2016 08:04 PM |
# 2
|
|
|
Hi Jerry -
Hmm, no, it is not. It is displaying: Tuesday Feb 29, 2000
My entry dates are correct, and if I add
{current_time format="%Y %m %d %H:%i:%s"}
it displays the correct time, but not with the DT code.
Also, when I change ‘hidden’ to ‘text’, nothing displays. I removed value = {expiration_date}” so now it reads:
<input type="text" name="expiration_date" value="{exp:dt set="{current_time}" month="3" format="%l %M %j, %Y"}">
Ideas?
|
|
|
jjpmann
|
Posted: 14 July 2016 09:54 PM |
# 3
|
|
|
you shouldn’t need set=”{current_time}” either as thats the default
does it work outside of the input tag?
does it work outside of the channel form tag?
|
|
|
jjpmann
|
Posted: 14 July 2016 10:04 PM |
# 4
|
|
|
I just tested in the latest ee3.3.4 and you should only need
<input name="expiration_date" value="{exp:dt month='3' format='utc'}"/>
here was the full template i used to test with just a blank channel named ‘test’
{exp:channel:form channel="test"}
<p>title <input name="title" value=""/></p>
<p>entry date <input name="entry_date" value="{current_time}"/></p> <p>expiration_date <input name="expiration_date" value="{exp:dt month='3' format='utc'}"/></p>
<input type="submit" value="add" />
{/exp:channel:form}
<hr> {exp:channel:entries channe="test"}
{title} : {entry_date format="%Y %m %d %H:%i:%s"} :: {expiration_date format="%Y %m %d %H:%i:%s"}<br>
{/exp:channel:entries}
|
|
|
susanfw
|
Posted: 14 July 2016 10:43 PM |
# 5
|
|
|
Jerry -
Your simplified code worked! I just added type=“hidden” to it.
<input type="hidden" name="expiration_date" value="{exp:dt month='3' format='utc'}"/>
Thank you so much, especially for helping so quickly.
Regards
Susan
|
|
|