Skip to:
Content
Pages
Categories
Search
Top
Bottom

Profile Fields Date format-> Range not working.


  • amitrwt
    Participant

    @amitrwt

    I want to set a profile field where a user will list his experience in a particular organization. From and To.. I tried Date -> Range but it just renders single dropdown. The best possible scenario would be having a datepicker with range.?
    I’ve installed BuddyPress Xprofile Custom Fields Type but even this doesn’t have a range date picker.
    Anyone has any suggestion/solution would be appreciated.

Viewing 5 replies - 1 through 5 (of 5 total)

  • Boone Gorges
    Keymaster

    @boonebgorges

    Hi @amitrwt – The ‘Start’ and ‘End’ fields in the BP admin settings define the start and end dates of a single datepicker. That is, if you want to have a datepicker, but you only want to show dates between the years 1970 and 1990, you’d use those dates as the Start and End.

    If you want your users to be able to select start and end times, my best suggestion is to create two separate xprofile fields, and name them accordingly: ‘Start Date’, ‘End Date’ or something like that.


    amitrwt
    Participant

    @amitrwt

    @boonebgorges

    If you want your users to be able to select start and end times, my best suggestion is to create two separate xprofile fields, and name them accordingly: ‘Start Date’, ‘End Date’ or something like that.

    That is exactly what I did, that was only way around I found for time being. If you have any insight can you pls tell me if it is possible to have a field with JQ datepicker where I can select start and end date. I’m planning to create a filed like this just need something to start with.. that’s the hard part once I’ll have a slate to start with I can write what I want. I’ve no issues getting my hands in code I’d rather enjoy it.


    Boone Gorges
    Keymaster

    @boonebgorges

    Sure, I’m happy to point you in the right direction.

    The BuddyPress Custom XProfile Field Type plugin is probably a good one to start with. It uses the BP_XProfile_Field_Type class to register its fields. It even has an existing Datepicker field that you can use as a starting place: https://github.com/donmik/buddypress-xprofile-custom-fields-type/blob/master/classes/Bxcft_Field_Type_Datepicker.php

    There are a few changes you’ll need to make in order for this to show two datepickers instead of one.

    – The set_format validation regex expects a single date. This will need to be modified for your new format. https://github.com/donmik/buddypress-xprofile-custom-fields-type/blob/1126cf093bd2b6e9f917b5c15f52e203f17cbb9e/classes/Bxcft_Field_Type_Datepicker.php#L14
    – You’ll need to modify the edit_field_html method so that it loads two separate input fields, and then write some JavaScript that assigns a jquery-datepicker to each one of them. Then you’ll need to write a little bit of extra JS that combines the two datepicker inputs into a single (probably hidden) field, which is the one that BP will actually save to the database. https://github.com/donmik/buddypress-xprofile-custom-fields-type/blob/1126cf093bd2b6e9f917b5c15f52e203f17cbb9e/classes/Bxcft_Field_Type_Datepicker.php#L29
    – If you decide to store the start and end date in a single row in the profile field, you’ll also need some logic that splits it into start and end when you load the edit_field_html. Another option is to store the concatenated display text – say, April 2017 - May 2017 – in BP’s native xprofile field, and to store the start and end date separately, as xprofilemeta. You’d need a custom save routine for this, but it may be a bit cleaner.

    Good luck! Sounds like a fun project.


    DenisCGN
    Participant

    @deniscgn

    Hello,
    can anyone help with this (somehow) dynamic range)?

    date range

    It somehow does no effect 🙁
    Cheers,
    Denis


    xalerafera
    Participant

    @xalerafera

    nicehacked

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.
Skip to toolbar