How to add a new Input Field Type?
hansolo Offline
Junior Member
**
Posts: 22
Joined: Sep 2015
Post: #11
RE: How to add a new Input Field Type?
OK thanks for the interest in this guys, I will try the things mentioned and report back.
09-18-2015 01:38 PM
Find all posts by this user Quote this message in a reply
hansolo Offline
Junior Member
**
Posts: 22
Joined: Sep 2015
Post: #12
RE: How to add a new Input Field Type?
OK I made the modifications. My code in my template looks like:

Code:
1
2
3
4
5
6
7
8
9
10
11
12
{$headerinclude}
<script type="text/javascript" src="{$mybb->asset_url}/jscripts/post.js?ver=1800"></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
<script type="text/javascript" src="{$mybb->asset_url}/jscripts/datepicker-en-GB.js"></script>
<script type="text/javascript">
  jQuery(function() {
  	jQuery("#datepicker").datepicker(
		{ dateFormat: "dd/mm/yyyy" }).val()
  	$.datepicker.setDefaults($.datepicker.regional["en-GB"]);
  });
</script>


Text mask filter: Date (dd/mm/yyyy)
Input formatter: <?=strtotime({VALUE})?>
Input field html: <input type="text" class="textbox"{NAME_PROP}{MAXLEN_PROP}{WIDTH_PROP_SIZE}{TABINDEX_PROP}{REQUIRED_PROP} value="{VALUE}" id="datepicker" />
Display parsing: plain text
Display format: <?=date('d-m-Y', {VALUE})?>

However I have two problems:
1) The jquery datepicker is being obscured by the message section. I guess this is something to do with some CSS code?
2) When I select a date, it enters it into the textbox like: "18/09/20152015" instead of like "18/09/2015" (which is what I want)

Any ideas whats wrong? Cheers!

09-18-2015 03:17 PM
Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #13
RE: How to add a new Input Field Type?
Have you tried it exactly as nier3 suggested it? She gives a full list of the custom field options.

For the date picker,yes, the z-index is too low - you need to set it at about 10000 to go over the sceditor


[Image: leelink.gif]
MYBB1.6 & XThreads
(This post was last modified: 09-18-2015 03:54 PM by leefish.)
09-18-2015 03:53 PM
Visit this user's website Find all posts by this user Quote this message in a reply
hansolo Offline
Junior Member
**
Posts: 22
Joined: Sep 2015
Post: #14
RE: How to add a new Input Field Type?
OK I fixed the z-index issue by adding style="position: relative; z-index: 10000;" to the input field html.
Everything else is the same as nier3 said, but I've made the date order dd/mm/yyyy like I want it to be.
09-18-2015 08:39 PM
Find all posts by this user Quote this message in a reply
hansolo Offline
Junior Member
**
Posts: 22
Joined: Sep 2015
Post: #15
RE: How to add a new Input Field Type?
OK the datepicker thing thinks "yy" means "yyyy", so that's fixed.
(This post was last modified: 09-18-2015 09:42 PM by hansolo.)
09-18-2015 09:41 PM
Find all posts by this user Quote this message in a reply
nier3 Offline
Member
***
Posts: 125
Joined: Jul 2012
Post: #16
RE: How to add a new Input Field Type?
(09-17-2015 06:31 AM)RateU Wrote:  Very nice Smile

I just want to add an idea to work also (hopefully) when editing draft and post preview (or when inline post error triggered):

Code:
<if (THIS_SCRIPT == 'editpost.php' && !$mybb->input['my_post_key']) || (THIS_SCRIPT == 'newthread.php' && $mybb->input['action'] == 'editdraft') then><?=date('m/d/Y',{VALUE})?><else>{VALUE}</if>


Also (if not saving it as string), maybe it is better (in my opinion) to set the Underlying Data Type to Integer.

I use pikaday though.


Hi RateU, I tried the code but doesn't work Frown

For now I'm using this:

Code:
1
2
3
4
5
6
7
8
9
<if THIS_SCRIPT == 'editpost.php' && !$GLOBALS['threadfields']['datexp'] then>

<input type="text" class="textbox"{NAME_PROP}{MAXLE​​N_PROP}{WIDTH_PROP_SIZE}{TABINDE​X​_PROP}{REQUIRED_PROP} value="<?=date('Y/m/d', (int){VALUE})?>" id="datepicker" placeholder="editpost" />

<else>

<input type="text" class="textbox"{NAME_PROP}{MAXLE​​N_PROP}{WIDTH_PROP_SIZE}{TABINDE​X​_PROP}{REQUIRED_PROP} value="{VALUE}" id="datepicker" placeholder="newthread" />

</if>


With this the problem still is if user doesn't add a date in the field and I edit (and then save) the thread I have "1970/01/01" date instead of an empty field.

For the rest is ok: if I create a new thread I haven't problem; if I edit a thread with an existent date I have correct date (and not a string like before).

Date in preview post doesn't work Frown

09-20-2015 11:20 AM
Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #17
RE: How to add a new Input Field Type?
Oh, so this is not a required field?
Maybe you can try this condition:

Code:
<if {VALUE} && !$mybb->input['my_post_key'] then><?=my_date('d-m-Y',{VALUE})?><else>{VALUE}</if>


The implementation is something like this:

HTML Code
1
2
3
4
5
6
<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" />
<link type="text/css" rel="stylesheet" href="cache/jquery-ui/jquery-ui.min.css" />
<script src="cache/jquery-ui/jquery-ui.min.js"></script>
<script>
	$(function(){$('#datepicker').datepicker({dateFormat:'dd-mm-yy',autoSize:true});});
</script>


09-21-2015 04:46 AM
Find all posts by this user Quote this message in a reply
nier3 Offline
Member
***
Posts: 125
Joined: Jul 2012
Post: #18
RE: How to add a new Input Field Type?
I tried all combinations of format date but only this works Frown

Code:
1
2
3
4
5
6
7
<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('Y/m/d',{VALUE})?><else>{VALUE}</if>" id="datepicker" />
<link type="text/css" rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css" />
<script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
<script src="/datepicker-it.js"></script>
<script>
	$(function(){$('#datepicker').datepicker({dateFormat:'yy/mm/dd',autoSize:true});});
</script>


Other format dates, when I do preview thread or submit thread, it says Invalid value. It works only with Y/m/d Frown

But on showthread the format date is correct, that is dd-mm-yy because in Display Format I use <?=date('d-m-Y', {VALUE})?> so it's a problem only in newthread / edit post, but always better that string of before Biggrin Not a big problem

And now if I don't add a date and I edit the thread it's perfect, I haven't more 1970-01-01 so it's awesome Biggrin Yipi Yipi Thanks

09-22-2015 09:29 AM
Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #19
RE: How to add a new Input Field Type?
(09-22-2015 09:29 AM)nier3 Wrote:  when I do preview thread or submit thread, it says Invalid value. It works only with Y/m/d Frown

Probably because of this:
(09-16-2015 10:25 PM)nier3 Wrote:  Text Mask Filter: Custom (regex) and write this: ^((?:19|20)\d\d)/(0?[1-9]|1[012])/(0?[1-9]|[12]\d|3[01])$

I use this Custom (regex) Text Mask Filter:

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

It is based on the default XThreads Date (dd/mm/yyyy) Text Mask Filter.


09-23-2015 12:29 AM
Find all posts by this user Quote this message in a reply
nier3 Offline
Member
***
Posts: 125
Joined: Jul 2012
Post: #20
RE: How to add a new Input Field Type?
With this I have again error "Invalid value", when I create new thread and when I edit a thread Frown

Custom 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('dd/mm/yyyy',{VALUE})?><else>{VALUE}</if>" id="datepicker" />


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

This custom thread field isn't required.


In the template:

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

  <script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
  <script src="/datepicker-it.js"></script>
  
<script type="text/javascript">
jQuery(function() {
jQuery("#datepicker").datepicker({ dateFormat: "dd/mm/yyyy" }).val()
$.datepicker.setDefaults($.datepicker.regional['it']);
});
</script>


I need string number in database for move automatically threads every day on date of expiration:

Code:
if ($result = @$mysqli->query("UPDATE mybb_threads 
    LEFT JOIN mybb_threadfields_data
    ON mybb_threads.tid=mybb_threadfields_data.tid
    SET mybb_threads.fid='130' WHERE mybb_threads.fid IN('128','73') AND mybb_threadfields_data.datexp > 0 AND mybb_threadfields_data.datexp < UNIX_TIMESTAMP(NOW())"))

09-23-2015 04:33 AM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: