solved Date drop down showing date when not entered

blindmime
@blindmime
10 years ago
772 posts
Is there a way to have date dropdown menu fields NOT show a date when there hasn't been a date entered?
updated by @blindmime: 04/23/15 05:20:24PM
brian
@brian
10 years ago
10,149 posts
Try setting the value to an empty string. The default is to use the current date.


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
blindmime
@blindmime
10 years ago
772 posts
How do I set the value to an empty string?
brian
@brian
10 years ago
10,149 posts
blindmime:
How do I set the value to an empty string?

'value' => ''

in the form field definition should work.


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
blindmime
@blindmime
10 years ago
772 posts
I put this in the update section of index.php:
 // Task Completed Date
    $_tmp = array(
        'name'      => 'task_completed_date',
	 'label'     => 'test label',
        'value' => ''
    );
    jrCore_form_field_create($_tmp);
But it's not changing anything about this item in the form. Even the label remains how I configured it in the form designer. I'm in developer mode, but I also ran an integrity check just in case.

Also, in form designer, I have ordered the items so a chained select field should appear at the 1st position, yet the Title field and another field, THEN the chained select field appear.
blindmime
@blindmime
10 years ago
772 posts
I looked at the source and there is a javascript affecting display of the date field:

<script type="text/javascript">
$(document).ready(function(){
try { $('#task_completed_date').glDatePicker({ onChange: function(target,newDate) { var yy = newDate.getUTCFullYear().toString(); var mm = (newDate.getMonth() + 1).toString(); var dd = newDate.getDate().toString(); target.val((mm[1] ? mm : "0" + mm[0]) +"/"+ (dd[1] ? dd : "0" + dd[0]) +"/"+ yy.substring(2)); } }); } catch(e) {};
try { $('#task_week').glDatePicker({ onChange: function(target,newDate) { var yy = newDate.getUTCFullYear().toString(); var mm = (newDate.getMonth() + 1).toString(); var dd = newDate.getDate().toString(); target.val((mm[1] ? mm : "0" + mm[0]) +"/"+ (dd[1] ? dd : "0" + dd[0]) +"/"+ yy.substring(2)); } }); } catch(e) {};

    try {
    var active_e0f3fd85_uploads = {};
    var active_e0f3fd85_ulcount = 0;
    var pm_task_photo = new qq.FileUploader({
        element: document.getElementById('pm_task_photo'),
        action: 'http://lfdgcare.com/core/upload_file/',
        inputName: 'pm_task_photo',
        acceptFiles: 'png,gif,jpg,jpeg',
        sizeLimit: 10485760,
        multiple: false,
        debug: true,
        params: { upload_name: 'task_photo', field_name: 'pm_task_photo', token: 'cb5a864b8c8aa5f44e8f6c8339e9c593', upload_token: '127487e5c8f66809a8d4c0ce66652051', extensions: 'png,gif,jpg,jpeg', multiple: 'false' },
        uploadButtonText: 'Upload a new Image',
        cancelButtonText: 'cancel',
        failUploadText: 'upload failed',
        onSubmit: function(id,fileName) {
            active_e0f3fd85_ulcount++;
            if (0 > 0 && active_e0f3fd85_ulcount > 0) { return false; }
        },
        onUpload: function(id,fileName) {
            active_e0f3fd85_uploads[fileName] = 1;
            $('.form_submit_section input').attr("disabled","disabled").addClass('form_button_disabled');
        },
        onComplete: function(id,fileName,response) {
            delete active_e0f3fd85_uploads[fileName]; var count = 0;
            for (i in active_e0f3fd85_uploads) { if (active_e0f3fd85_uploads.hasOwnProperty(i)) { count++; } }
            if (count === 0) { $('.form_submit_section input').removeAttr("disabled","disabled").removeClass('form_button_disabled'); }
        }
    });
    } catch(e) {}
return true;
});
</script>

updated by @blindmime: 03/06/15 12:45:49AM
blindmime
@blindmime
10 years ago
772 posts
Seeing a date in the field when nothing has been entered has always been confusing to me. I naturally think it's a value that's been entered. Now I have a client complaining of the same thing.
brian
@brian
10 years ago
10,149 posts
Yes - Javascript will of course be affecting the field since the calendar is a javascript calendar :)

I'll have to see if this is possible at this time and will let you know.


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
brian
@brian
10 years ago
10,149 posts
This is supported in Core 5.2.27 - just do:

'value' => false

Hope this helps!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
blindmime
@blindmime
10 years ago
772 posts
It doesn't seem to be doing anything at all.
brian
@brian
10 years ago
10,149 posts
blindmime:
It doesn't seem to be doing anything at all.

We're using it here now on jamroom.net (for new quota start date in profile settings) and I don't see any issues. You're on 5.2.27?


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
blindmime
@blindmime
10 years ago
772 posts
Yes, 5.2.27

This is what I have right now in the update section of the module's index.php:

 // Task Completed Date
    $_tmp = array(
        'name'      => 'task_completed_date',
	 'label'     => 10653,
        'value' => false
    );
    jrCore_form_field_create($_tmp);
michael
@michael
10 years ago
7,794 posts
There is no type. What type of form field is it?
blindmime
@blindmime
10 years ago
772 posts
I've done it with and without a type of 'date'. Doesn't seem to do anything either way.

I've tried changing the value of a different 'text' type field, just to see, and that does work.
michael
@michael
10 years ago
7,794 posts
its got to have a type.

Here is what one from the blog module looks like:
    // Blog Publish Date
    $_tmp = array(
        'name'     => 'blog_publish_date',
        'label'    => 22,
        'help'     => 23,
        'type'     => 'datetime',
        'validate' => 'date',
        'required' => false
    );
    jrCore_form_field_create($_tmp);

Try adding 'value' => false to that structure

    $_tmp = array(
        'name'     => 'task_completed_date',
        'label'    => 10653,
        'help'     => 'whatever help text your after goes in here...',
        'type'     => 'datetime',
        'validate' => 'date',
        'value'    => false,
        'required' => false
    );
    jrCore_form_field_create($_tmp);
blindmime
@blindmime
10 years ago
772 posts
It's not working. I pasted the above and nothing happens. Nothing in help either.

Do I need to delete the field out of the form designer or something like that? It seems like something is overwriting the index.php entry.
updated by @blindmime: 03/10/15 07:58:14AM
brian
@brian
10 years ago
10,149 posts
blindmime:
It's not working. I pasted the above and nothing happens. Nothing in help either.

Do I need to delete the field out of the form designer or something like that? It seems like something is overwriting the index.php entry.

If it is form designer and you are just testing, yes - remove it from form designer since form designer "override" what you put in the code.


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
blindmime
@blindmime
10 years ago
772 posts
I'm not just testing, it's a live system. Can you please tell me what happens when I delete the form field from the form designer and put this code in index.php? I'm guessing the data is not deleted, but want to be sure of what happens. It sounds from your comment above that something might happen though.
brian
@brian
10 years ago
10,149 posts
blindmime:
I'm not just testing, it's a live system. Can you please tell me what happens when I delete the form field from the form designer and put this code in index.php? I'm guessing the data is not deleted, but want to be sure of what happens. It sounds from your comment above that something might happen though.

If you delete the field from the form designer, it will be deleted from the form designer and your PHP code will take over.

You might want to test on a staging system if you can ;)


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
blindmime
@blindmime
10 years ago
772 posts
I'll give that a shot, but the issue with having the date default and actually ENTER the current date means that the current date is entered regardless of whether you want to actually enter a date or not. There are many cases you do not want to enter a date. Such as when the date is a completion date, or when you don't yet know the date for whatever reason. Many other cases.
blindmime
@blindmime
10 years ago
772 posts
This aparna-generated module seems to be doing odd things. I've been testing on a newly generated module. Created a date field with the form designer. Created a couple test items. Then deleted the date field in the form designer and added the code above in index.php. The date still defaults to the current date. But also if I then delete the above code from index.php, after having deleted the field from form designer, it still shows up in form designer. I tried adding the above code in index.php giving it a datatime type and it shows up in the form designer along with the other one, so there's TWO fields now called the same thing.

I just want a date field that doesn't require a value until I actually give it a value.
screenshot_249.jpg
screenshot_249.jpg  •  48KB


updated by @blindmime: 03/15/15 10:08:56PM
SteveX
SteveX
@ultrajam
10 years ago
2,584 posts
You have both test_ and task_ as the prefix - that can't be right.


--
¯\_(ツ)_/¯ Education, learning resources, TEL, AR/VR/MR, CC licensed content, panoramas, interactive narrative, sectional modules (like jrDocs), lunch at Uni of Bristol. Get in touch if you share my current interests or can suggest better :)
blindmime
@blindmime
10 years ago
772 posts
Thanks, Steve. I'll look at that.

What the client is seeing in the working module is this. It has to do with how a date is shown in a form as opposed to how it shows up in a template:
Quote:
Still having an issue with the completed date L
If I am looking at the list of tasks completed and entered in March [client is looking at jrCore_list template] , the complete date shows yesterday’s date, which is correct. But if I open up the task to get all of the detailed info [now she is looking at the update form] , the complete date changes and shows whatever date it actually is.
When I exit out of the task, and go back to the list of tasks completed in March, the completed date shows 3/16/15 again [she's back on the jrCore list template] .
Why does it do this??

What is happening is the form shows whatever today's date is regardless of what's been entered or even if nothing has been entered. The date should show if it's been entered and nothing should show if nothing has been entered. At least that is what I think should happen.
blindmime
@blindmime
10 years ago
772 posts
I have a very upset client due to this issue. I believe something has changed in jamroom. We weren't experiencing this issue last year.

The date in this field is changing to the current date whenever the form is updated. Not just the form display, but the actual data is being changed when updated.

Why?
brian
@brian
10 years ago
10,149 posts
blindmime:
I have a very upset client due to this issue. I believe something has changed in jamroom. We weren't experiencing this issue last year.

The date in this field is changing to the current date whenever the form is updated. Not just the form display, but the actual data is being changed when updated.

Why?

I am not sure - A LOT of things have changed over the last year.

Is the date field that is changing part of a core module? A cloned module? A custom form field?

Thanks!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
michael
@michael
10 years ago
7,794 posts
blindmime:.......The date in this field is changing to the current date whenever the form is updated....
The _created date on a datastore item should never change. That is the date the item went into the datastore.

The _updated date changes everytime the item is edited and saved.
blindmime
@blindmime
10 years ago
772 posts
I guess I'll start over.

This is an Aparna-generated module. There is no custom coding to the module beyond what is provided by Aparna. I have added a "task_completed_date" field via the form designer with a date type. This is viewable in the update form. There is also a checkbox type field called "task_complete".

This module schedules tasks for maintenance people out in the field working on various Property profiles. When the task_complete checkbox hasn't been checked, then the task appears in their list of tasks to complete.

This is used in spring, summer, fall. It was used last year and now is being used again.

Last year, the client could update a task and there would be no date in the date field until she entered one. Or so she says, I'm thinking the current date would be showing since I've seen this happen on another jamroom site I have. The current will show in a date field when nothing has been entered.

What we do agree on is that showing the current date in the form when nothing has been entered is very confusing. You assume the date has been entered already.

This thread was started because I wanted a way to NOT show a date in the update form when nothing has previously been entered.

You gave me some code to place in the module's index.php file (see above). When I did that, it didn't change the update form display of task_completed_date (it still shows the current date). However, what does change is that the current date value is actually ENTERED as the task_completed_date even when the client doesn't click on the date and enter it via the javascript calendar. It also overrides values that have been entered when the form is updated.

Hopefully that makes sense.
brian
@brian
10 years ago
10,149 posts
blindmime:
I guess I'll start over.

This is an Aparna-generated module. There is no custom coding to the module beyond what is provided by Aparna. I have added a "task_completed_date" field via the form designer with a date type. This is viewable in the update form. There is also a checkbox type field called "task_complete".

This module schedules tasks for maintenance people out in the field working on various Property profiles. When the task_complete checkbox hasn't been checked, then the task appears in their list of tasks to complete.

This is used in spring, summer, fall. It was used last year and now is being used again.

Last year, the client could update a task and there would be no date in the date field until she entered one. Or so she says, I'm thinking the current date would be showing since I've seen this happen on another jamroom site I have. The current will show in a date field when nothing has been entered.

What we do agree on is that showing the current date in the form when nothing has been entered is very confusing. You assume the date has been entered already.

This was changed a version or 2 ago to not show, so this no longer should be an issue.

blindmime:
This thread was started because I wanted a way to NOT show a date in the update form when nothing has previously been entered.

That is how it works now.

Quote:
You gave me some code to place in the module's index.php file (see above). When I did that, it didn't change the update form display of task_completed_date (it still shows the current date). However, what does change is that the current date value is actually ENTERED as the task_completed_date even when the client doesn't click on the date and enter it via the javascript calendar. It also overrides values that have been entered when the form is updated.

Hopefully that makes sense.

I think I understand - basically even though no date is shown in the date field, on SAVE the current date is being saved.

Let me know if that sounds right - I'll check out the code and see if we have some sort of "default" handler adding that in.


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net

updated by @brian: 03/20/15 09:32:31AM
brian
@brian
10 years ago
10,149 posts
I believe I found the root cause of this - update to jrCore 5.2.28 and let me know if is fixed now.

Thanks!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
michael
@michael
10 years ago
7,794 posts
Loved that explanation. Real clean clear and easy to understand.

I would have suggested adding a default value of '' to the form field, but check out brians latest core update first.

If that fails, try adding:
'default' => ''
blindmime
@blindmime
10 years ago
772 posts
I'm not seeing any difference. The current date still shows. I'm seeing it on two different sites.

See the fields in the attached image with 3/22/15 showing in the field. Both date fields are showing the current date before anything has been entered. When seeing them there you think the date has already been entered.

By the way, I've removed any custom code in index.php for this field, so whatever form designer is doing, this is the result.
screenshot_252.jpg
screenshot_252.jpg  •  44KB


updated by @blindmime: 03/22/15 02:44:41PM
brian
@brian
10 years ago
10,149 posts
Contact me at support [at] jamroom [dot] net with your site admin and FTP info so I can check it out - I don't see any issues here.

Thanks!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
blindmime
@blindmime
10 years ago
772 posts
Due to the fact that this behavior is consistent on all my jamroom sites, I'm guessing I'm not explaining the issue sufficiently.

I'll send over the credentials.
blindmime
@blindmime
10 years ago
772 posts
Brian gave me the solution to this. Enter "false" as a default value in the form designer.
brian
@brian
10 years ago
10,149 posts
blindmime:
Brian gave me the solution to this. Enter "false" as a default value in the form designer.

Thanks for the update here - I normally come back and post a follow up, but thanks for doing it :)


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net

Tags