How to add a new Input Field Type?
nier3 Offline
Member
***
Posts: 125
Joined: Jul 2012
Post: #3
RE: How to add a new Input Field Type?
Hi, I use this code. I use this to move threads on date of expiration. If you want only datepicker on input field, please follow this more easy tutorial:
http://mybbhacks.zingaburga.com/showthre...http://mybbhacks.zingaburga.com/showthread.php?tid=5195&pid=1879

---------------------------------

- Download your language and add on your server: https://github.com/jquery/jquery-ui/tree/master/ui/i18n

- In newthread template, after {$headerinclude} and <script type="text/javascript" src="{$mybb->asset_url}/jscripts/post.js?ver=1800"></script> add:

Code:
1
2
3
4
5
6
7
8
9
10
11
12
  <link rel="stylesheet" href="//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css">

  <script src="//code.jquery.com/jquery-1.10.2.js"></script>
  <script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
  <script src="your-link-to script-datepicker-XX.js"></script>
  
  <script type="text/javascript">
jQuery(function() {
jQuery("#datepicker").datepicker({ dateFormat: "yy/mm/dd" }).val()
$.datepicker.setDefaults($.datepicker.regional[YOUR-LANGUAGE-EG-IT]);
});
</script>


- Settings in Custom Thread Fields for this date input field:

Input filed type: textbox
Text Mask Filter: Custom (regex) and write this: ^((?:19|20)\d\d)/(0?[1-9]|1[012])/(0?[1-9]|[12]\d|3[01])$
Input Formatter: <?=strtotime({VALUE})?>
Input Field HTML: yes and write this:

Code:
<input type="text" class="textbox"{NAME_PROP}{MAXLEN_PROP}{WIDTH_PROP_SIZE}{TABINDEX_PROP}{REQUIRED_PROP} value="{VALUE}" id="datepicker" />

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

You should to have a thing like this:

[Image: Omfqjr8.png]

Anyway this isn't perfect, when you edit a thread with this input field you will have to always edit this right date, because the date will be a string:

[Image: h8yDGvZ.png]

I still don't understand how to fix this Frown

An old thread about this is also here: http://mybbhacks.zingaburga.com/showthre...http://mybbhacks.zingaburga.com/showthread.php?tid=4

(This post was last modified: 09-17-2015 12:46 AM by nier3.)
09-16-2015 10:25 PM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

Messages In This Thread
RE: How to add a new Input Field Type? - nier3 - 09-16-2015 10:25 PM

 Standard Tools
Forum Jump: