How to add a new Input Field Type?
RateU Offline
Administrator
*******
Posts: 2,325
Joined: Mar 2010
Post: #21
RE: How to add a new Input Field Type?
If you want d-m-Y date format in newthread and editpost, you need to set the format into my_date('d-m-Y',{VALUE}) in your input text and use dd-mm-yyyy in your Javascript (see my example before), then use the Custom regex (the new Custom regex uses - as separators, not /).

09-23-2015 05:14 AM
Find all posts by this user Quote this message in a reply
nier3 Offline
Member
***
Posts: 124
Joined: Jul 2012
Post: #22
RE: How to add a new Input Field Type?
Thank youuuuu Rate Biggrin Biggrin Biggrin Now works perfectly!

So the code is:

Text Mask Filter (regex): ^(0?[1-9]|[12]\d|3[01])\-(0?[1-9]|1[012])\-((?:19|20)\d\d)$

Input Formatter: <?=strtotime({VALUE})?>

Input Field HTML:

Code:
<input type="text" class="textbox"{NAME_PROP}{MAXLE​​N_PROP}{WIDTH_PROP_SIZE}{TABINDE​X​_PROP}{REQUIRED_PROP} value="<if {VALUE} && !$mybb->input['my_post_key'] then><?=my_date('d-m-Y',{VALUE})?><else>{VALUE}</if>" id="datepicker" />


Display Format: <?=date('d-m-Y', {VALUE})?>

Now when I edit or create a new thread I haven't more problems with format date and if I don't add a date isn't a problem. And no problem with 1970 Biggrin

Thank you again Biggrin

09-23-2015 08:07 AM
Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,325
Joined: Mar 2010
Post: #23
RE: How to add a new Input Field Type?
Glad you can solve it. Nice usage of custom field Smile

09-25-2015 05:17 AM
Find all posts by this user Quote this message in a reply
ollie2015 Offline
Member
***
Posts: 90
Joined: Jan 2015
Post: #24
RE: How to add a new Input Field Type?
is there a JS to add a time to the date? thanks

Quote:I use this to move threads on date of expiration

AND do you do it automatically with a task or manually

ALSO
what regex would i need for

Code:
16/09/2015 00:00


and date and time format?

my_date('d-m-Y H:i',{VALUE})

EDIT: I am having trouble with timezone i guess, 7hrs behind, but why? I add the date and then edit the post and its 7 hrs behind....

how can i correct this?

(This post was last modified: 09-26-2015 12:10 AM by ollie2015.)
09-25-2015 01:51 PM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,338
Joined: Jan 2008
Post: #25
RE: How to add a new Input Field Type?
(09-25-2015 01:51 PM)ollie2015 Wrote:  is there a JS to add a time to the date? thanks

Javascript Code
new Date(new Date('2000-01-01 12:00:22') + 3600*1000).toString()


(09-25-2015 01:51 PM)ollie2015 Wrote:  ALSO
what regex would i need for

Code:
16/09/2015 00:00

Code:
^\d\d/\d\d/\d\d\d\d \d\d\:\d\d$

May vary depending on what validation you want and pattern capturing.

(09-25-2015 01:51 PM)ollie2015 Wrote:  my_date('d-m-Y H:i',{VALUE})

EDIT: I am having trouble with timezone i guess, 7hrs behind, but why? I add the date and then edit the post and its 7 hrs behind....

how can i correct this?
If you're applying the timezone correction twice, then times are going to be off.  Don't use my_date if you intend to use it later, because it will correct timezone (use date instead).

My Blog
10-29-2015 01:19 PM
Find all posts by this user Quote this message in a reply
hansolo Offline
Junior Member
**
Posts: 22
Joined: Sep 2015
Post: #26
RE: How to add a new Input Field Type?
Hi,

I still have a problem with this, same topic.

If I already have an existing thread, and I edit the Original Post, the "date" field (which has the datepicker) shows up as the unix time integer.

If I then click on that textbox, and pick a date, it shows up in the right dd-mm-yy format. How do I make it show in the right format as soon as editpost.php loads?

Cheers!
(This post was last modified: 03-13-2016 09:38 PM by hansolo.)
02-21-2016 11:51 PM
Find all posts by this user Quote this message in a reply
hansolo Offline
Junior Member
**
Posts: 22
Joined: Sep 2015
Post: #27
RE: How to add a new Input Field Type?
Edit: scratch that. I got confused how to combine the code in the above posts.

Fixed it as follows:

Used this Input Field HTML:

Code:
1
2
3
4
5
6
7
8
9
<if THIS_SCRIPT == 'editpost.php' && !isset($mybb->input['processed']) then>

<input type="text" class="textbox"{NAME_PROP}{MAXLE​​N_PROP}{WIDTH_PROP_SIZE}{TABINDE​X​_PROP}{REQUIRED_PROP} value="<?=date('d-m-Y', (int){VALUE})?>" id="datepicker" style="position: relative; z-index: 10000;" />

<else>

<input type="text" class="textbox"{NAME_PROP}{MAXLE​​N_PROP}{WIDTH_PROP_SIZE}{TABINDE​X​_PROP}{REQUIRED_PROP} value="{VALUE}" id="datepicker" style="position: relative; z-index: 10000;" />

</if>

(This post was last modified: 03-14-2016 03:10 AM by hansolo.)
03-11-2016 01:24 AM
Find all posts by this user Quote this message in a reply
hansolo Offline
Junior Member
**
Posts: 22
Joined: Sep 2015
Post: #28
RE: How to add a new Input Field Type?
Update: It isn't enough just to check if the script is 'editpost.php'.

If the user clicks preview, or makes an error on attempting to submit the edit, editpost.php passes the text value of the textbox to the next page. This text value then gets put through the date() function, leading to the 1970 date problem.

The solution is to check if the 'processed' flag is set:

Code:
<if THIS_SCRIPT == 'editpost.php' && !isset($mybb->input['processed']) then>


Updated the previous post's code.

03-14-2016 03:15 AM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: