Jump to:

10928 Posts in 2612 Topics by 1809 members

All other Modules

SilverStripe Forums » All other Modules » Memberprofiles - Check email field only accept valid email

Discuss all other Modules here.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1 2
Go to End
Author Topic: 1946 Views
  • Josua
    Avatar
    Community Member
    86 Posts

    Memberprofiles - Check email field only accept valid email Link to this post

    Hi!

    I'm trying to use the memberprofiles module, but I have a doubt:
    Do you know how to make the email field only accept valid email address?

    I mean a valid email format, not the validation through the use of sending an email.
    Ie
    martin -- incorrect email
    martin@ -- incorrect email
    martin@hotmail -- incorrect email
    martin@hotmail.com -- correct email

    Thanks,
    Regards,
    Jose

  • Josua
    Avatar
    Community Member
    86 Posts

    Re: Memberprofiles - Check email field only accept valid email Link to this post

    Hi all!

    Does anyone know how to do this?

    Thanks,
    Regards,
    Jose

  • novaweb
    Avatar
    Community Member
    111 Posts

    Re: Memberprofiles - Check email field only accept valid email Link to this post

    Hola Jose,

    (I haven't looked in to member profiles, but)

    In the registration form, use the following form field type:

    new EmailField("Email")

    This will parse the email supplied and check it is valid.

  • Josua
    Avatar
    Community Member
    86 Posts

    Re: Memberprofiles - Check email field only accept valid email Link to this post

    Hello Josh!

    Ok, but I would have liked to do it without having to modify the code directly from the module.

    Do you know if there is another way to do this?

    Regards,
    Jose

  • ajshort
    Avatar
    Community Member
    244 Posts

    Re: Memberprofiles - Check email field only accept valid email Link to this post

    The form fields are generated by Member::getMemberFormFields(). You can modify the fields using an updateMemberFormFields method in an extension applied to Member - so all you need to do is create an extension/decorator applied to the Member class, and have an updateMemberFormFields method which replaces the Email field with an EmailField.

  • Josua
    Avatar
    Community Member
    86 Posts

    Re: Memberprofiles - Check email field only accept valid email Link to this post

    Hello Andrew!

    Uhhhmmmm!! That sounds interesting.
    I'm beginner in SilverStripe, but I will try to do what you tell me, I'll tell you something.
    By the way, is there any easy way to integrate memberprofiles with the forum module?

    Thanks you very much for your reply.

    Regards,
    Jose

  • Josua
    Avatar
    Community Member
    86 Posts

    Re: Memberprofiles - Check email field only accept valid email Link to this post

    Hello Andrew!

    I tried your instructions, but does not work:

    MyMember.php

    class MyMember extends DataObjectDecorator {
    public function updateMemberFormFields(&$fields) {
    $fields->removeByName('Email');
    $fields->push(new EmailField('Email', 'Email address22'));
    }

    _config.php

    Object::add_extension('Member', 'MyMember');

    http://127.0.0.1/dev/build?flush=all

    I have verified that the field has been changed, since it show 'Email address22', however, the field email continues to accept any text, it does not check to be a valid mail.

    To verify that I had no problem in another part of my project I created a sample form (manually) that included a EmailField.
    In that form everything works perfectly, and this field (EmailField) only accepts valid email formats, besides, in that form automatically works the javascript validation (client-side), while in the memberprofiles module it does not work.
    It is obviously a problem of the memberprofiles module, not of my project.
    Maybe I need to configure something else in the memberprofiles module?

    What can be happening?
    Do I have to do something more in order that it works?

    Please, help, thanks,
    Regards,
    Jose

  • Josua
    Avatar
    Community Member
    86 Posts

    Re: Memberprofiles - Check email field only accept valid email Link to this post

    Hello Andrew!

    I already have discovered what it is the problem for the which the EmailField control not work.
    You have disabled the javascript validation in your MemberProfileValidator class.

       /**
        * JavaScript validation is disabled on profile forms.
        */
       public function javascript() {
          return null;
       }

    The EmailField control only works if the Javascript is enabled.

    Why you've disabled javascript validation for memberprofiles module ?
    Is there a compelling reason ?

    What can I do in order that the control Emailfield work correctly?

    Thanks,
    Regards,
    Jose

    1946 Views
Page: 1 2
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.