Jump to content

Disable InputfieldPassword


pwFoo
 Share

Recommended Posts

How to disable the InputfieldPassword input fields?

$pass = $form->get('password');
$pass->attr('disabled', true);

With the example above the password field is disabled, but the "confirm" input field is enabled.

Link to comment
Share on other sites

Not sure your exact scenario, but I have made use of:

$this->addHookBefore('InputfieldPassword::processInput', $this, 'removeRequired');

public function removeRequired(HookEvent $event) {
    $event->object->required = false; //hack to remove required status on password field
}

From memory it's not possible to set the status of the password field directly to not required.

I know this is not the same as disabled, but now you should be able to disable or hide it and should work as expected I think.

One thing to keep in mind, the system password field is actually named "pass", not "password" like you have there.

  • Like 2
Link to comment
Share on other sites

Hi Adrian,

thank you for your reply, but that is not what I need.

If you set InputfieldPassword to hidden or disabled only the password field named password will be affected, but there is a second field (confirmation!) named _password. Here you can see the markup generated by InputfieldPassword (only input elements).

<p><input id="password" class=" required" name="password" type="password" size="50" maxlength="256" disabled="1" /></p>
<p><input type='password' size='50' name='_password' value='' /> <span class='detail'>(confirm)</span></p>

Haven't found a way to disable both fields via field settings. 

Link to comment
Share on other sites

  • 1 year later...

Would be nice if password field were actually made required by field settings, but thanks a lot for the hook adrian :D

just wanted to unrequire pass field because not all user need a pass as some might only be staff entry to show on the front page and I just confirmed that an empty password wont allow login..I like!

maybe it could be deactivatable in advanced mode

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...