We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • What is the placeholder for the Date of Birth field for UpdateProfile - this is an available field but I can’t seem to find any reference to it anywhere. Very close to completing this clients site and now just last little tweaks.

    Have tried the following, but it doesn’t work:

    <label for="dateofbirth">[[!%login.dateofbirth]]
    <span class="error">[[+error.dateofbirth]]</span>
    </label>
    <input type="text" name="dob" id="dob" value="[[+dateofbirth]]" />

    Tried creating a lexicon entry for login.dateofbirth which did indeed load up a label name of Date of Birth: but the input isn’t being recorded.

    Suggestions please. Thanks smiley
      Helen Warner
      Number one pixel!
      Proud to be linked with MODX at Crimson Pixel
      • 14877
      • 110 Posts
        __________________
        JRG
      • Thanks for that, have changed the parameters to [[+dob]] but the date doesn’t show in the profile. I’m using the following in my input string - this may of course not be correct.

        <label for="dateofbirth">[[!%login.dob]] <span class="error">[[+error.dob]]</span> </label> <input id="dob" name="dob" type="date" value="[[+dob]]" />

        When a date of birth is added to the User profile within the Manager the date is not returned in date format on the form. My example is input date
        11-04-1965
        and the output value using [[+dob]] is
        -149126400

        Suggestions please? This is last piece of puzzle for creating my clients profile form.
          Helen Warner
          Number one pixel!
          Proud to be linked with MODX at Crimson Pixel
        • That’s a UNIX timestamp (dates before 1970 are in negative notation). Your input function is converting it; and wrongly at that, as the PHP date() function returns it as 04-11-1965. It has something to do with the input processing function thinking it’s US-style time if - is used and Europe style if / is used or something like that undecided
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
          • Hi Susan thanks for speedy response - the date requirement is European (UK) and the string format that I would like to return is
            %d %m %Y
              Helen Warner
              Number one pixel!
              Proud to be linked with MODX at Crimson Pixel
              • 24687
              • 14 Posts
              Here’s an awesome peace of code I use every time if using the jquery datepicker.
              I don’t originally know where I got the snippet from but in this case it should help ( I think )
              $('.date-human').datepicker({
                  'dateFormat':'yy-mm-dd'
                });
              

              function convert_date(){
                var $this=$(this);
                var id='date-input-'+Math.random().toString()
                  .replace(/\./,'');
                var dparts=$this.val().split(/-/);
                $this
                  .datepicker({
                    dateFormat:'yy-mm-dd',
                    modal:true,
                    altField:'#'+id,
                    altFormat:'DD, d MM, yy',
                    onSelect:function(dateText,inst){
                      this.value=dateText;
                    }
                  });
                var $wrapper=$this.wrap(
                    '<div style="position:relative" />');
                var $input=$('<input id="'+id+'" class="date-human-readable"
                    value="'+date_m2h($this.val())+'" />');
                $input.insertAfter($this);
                $this.css({
                  'position':'absolute',
                  'opacity':0
                });
                $this
                  .datepicker(
                    'setDate', new Date(dparts[0],dparts[1]-1,dparts[2])
                  );
              }
              $(function(){
                $('input.date-human').each(convert_date);
              });
              


              So instead of the db version of yyyy-mm-dd you get day, month, year
              I don’t know if modx already does this but I think this should help you get what you’re wanting to achieve.
              • The problem isn’t about being able to enter a date it is what is returned from the [[+dob]] field. I can enter the date 11-04-1965 in the manager and what is returned on the front end is:

                Date of birth: -149130000

                Until I’ve figured out how this is altered having a date picker isn’t going to help - although I will hang to this for when a resolution is found wink
                  Helen Warner
                  Number one pixel!
                  Proud to be linked with MODX at Crimson Pixel
                  • 24687
                  • 14 Posts
                  Well for News and Blog posts I use this to display the date.
                  [[+publishedon:strtotime:date=`%d, %b, %Y`]]

                  I’ve forgot what that’s apart of now, I don’t know if it’s part of the core of modx or if it’s a part of quip, I think it might even be getResources. Never the less you’ve got more experience than me and I’m pretty sure you’ve seen it before. All I would do is mimic that process exactly the same but instead of publishedon I’d put dob.

                  Then again I think I may be miss understanding this again.
                  I’ll have the same problem tomorrow when I come to making the user profiles page. I’ll let you know how I got on.
                    • 3749
                    • 24,544 Posts
                    Revo returns a date string for the resource fields (createdon, publishedon, etc) but apparently not for dob. Try this :

                    [[*dob:date=`%d %m %Y`]]
                      Did I help you? Buy me a beer
                      Get my Book: MODX:The Official Guide
                      MODX info for everyone: http://bobsguides.com/modx.html
                      My MODX Extras
                      Bob's Guides is now hosted at A2 MODX Hosting
                    • Nope tried those options and doesn’t return anything. huh

                      Did try the following too:
                      [[+dob:date=`%d %b %Y`]] or [[+dob:date=`%d %m %Y`]]

                      But no joy yet.
                        Helen Warner
                        Number one pixel!
                        Proud to be linked with MODX at Crimson Pixel