Sign in to follow this  
modifiedcontent

Get the same 'set password' form on the front-end

Recommended Posts

How do you get the same 'set password' form/input fields on the front-end as in the admin area?

I have a working front-end version, but the admin version has some nifty stuff around it. Should be easy to get the same on the front-end, right?

Share this post


Link to post
Share on other sites

The nifty code:

$base = wire('config')->urls;
$cssUrl = $base->InputfieldPassword."InputfieldPassword.css";
echo '<link rel="stylesheet" href="'.$cssUrl.'">';

$jsUrls = array();
$jsUrls[] = $base->InputfieldPassword."complexify/jquery.complexify.min.js";
$jsUrls[] = $base->InputfieldPassword."complexify/jquery.complexify.banlist.js";
$jsUrls[] = $base->JqueryCore."xregexp.min.js";
$jsUrls[] = $base->InputfieldPassword."InputfieldPassword.min.js";

foreach ($jsUrls as $jsUrl) {
	echo "<script src='$jsUrl'></script>";
}

 

  • Like 2

Share this post


Link to post
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

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Typografics
      Hello,
      I've been developing a general settings module for our websites. I'm storing the settings data in the module config data, but I can't seem to get the data working at the front-end of our website.
      I'm trying to call the data in my template like this:
      modules()->getConfig('TypoSettings'); Wich returns me an empty array. Am I doing something wrong? Or has it something to do with module permissions?
      Full module code:
      <?php namespace ProcessWire; /* * TypoSettings */ class TypoSettings extends Process implements Module, ConfigurableModule { public static function getModuleInfo() { return array( 'title' => "TypoSettings", 'version' => "0.0.1", 'summary' => "An awesome module for saving your general site settings.", 'author' => "Jonathan Claeys", 'href' => "", 'icon' => "cog", 'autoload' => false, 'singular' => true, 'requires' => "ProcessWire>=2.5", "permissions" => array( "setting-view" => "View the general sitewide settings.", "setting-edit" => "Edit the general sitewide settings." ), ); } public function init(){ modules()->get('JqueryWireTabs'); parent::init(); } public function ___execute(){ return $this->createForm($this->getDefaultData()); } static public function getDefaultData(){ return array( /* * General */ 'settings_general_tab' => array( 'type' => 'InputfieldTab', 'label' => __('General') ), 'settings_client' => array( 'type' => 'InputfieldText', 'label' => __('Client'), 'value' => 'Typografics', 'required' => 1 ), 'settings_email' => array( 'type' => 'InputfieldEmail', 'label' => __('E-mail'), 'value' => 'info@typografics.be', 'required' => 1 ), 'settings_telephone' => array( 'type' => 'InputfieldText', 'label' => __('Telephone'), 'value' => '', 'required' => 0 ), 'settings_fax' => array( 'type' => 'InputfieldText', 'label' => __('Fax'), 'value' => '', 'required' => 0 ), 'settings_general_tab_end' => array( 'type' => 'InputfieldTabEnd' ), /* * Location */ 'settings_location_tab' => array( 'type' => 'InputfieldTab', 'label' => __('Location') ), 'settings_address' => array( 'type' => 'InputfieldText', 'label' => __('Address'), 'value' => 'Zwaarveld 45', 'required' => 1 ), 'settings_postal_code' => array( 'type' => 'InputfieldText', 'label' => __('Postal code'), 'value' => '9220', 'required' => 1, 'columnWidth' => 33 ), 'settings_city' => array( 'type' => 'InputfieldText', 'label' => __('City'), 'value' => 'Hamme', 'required' => 1, 'columnWidth' => 67 ), 'settings_location_tab_end' => array( 'type' => 'InputfieldTabEnd' ), /* * Social media */ 'settings_social_tab' => array( 'type' => 'InputfieldTab', 'label' => __('Social media') ), 'settings_facebook' => array( 'type' => 'InputfieldText', 'label' => __('Facebook'), 'value' => '', 'required' => 0 ), 'settings_linkedin' => array( 'type' => 'InputfieldText', 'label' => __('LinkedIn'), 'value' => '', 'required' => 0 ), 'settings_google_plus' => array( 'type' => 'InputfieldText', 'label' => __('Google Plus'), 'value' => '', 'required' => 0 ), 'settings_twitter' => array( 'type' => 'InputfieldText', 'label' => __('Twitter'), 'value' => '', 'required' => 0 ), 'settings_pinterest' => array( 'type' => 'InputfieldText', 'label' => __('Pinterest'), 'value' => '', 'required' => 0 ), 'settings_instagram' => array( 'type' => 'InputfieldText', 'label' => __('Instagram'), 'value' => '', 'required' => 0 ), 'settings_social_tab_end' => array( 'type' => 'InputfieldTabEnd' ), ); } public function __construct(){ foreach (self::getDefaultData() as $key => $value) { $this->$key = $value; } } static public function getModuleConfigInputfields(array $data) { $defaults = self::getDefaultData(); $data = array_merge($defaults, $data); $fields = new InputfieldWrapper(); foreach($data as $key => $inputfield){ if (!isset($inputfield['type'])) { continue; } switch ($inputfield['type']){ case 'InputfieldTab': break; case 'InputfieldTabEnd': break; default: $field = modules()->get($inputfield['type']); $field->attr('id+name', $key); $field->label = $inputfield['label']; $field->required = $inputfield['required']; $field->value = $data[$key]['value']; $fields->append($field); } } return $fields; } public function createForm($inputfields){ /* * Create form */ $form = $this->modules->get('InputfieldForm'); $form->action = './'; $form->method = 'post'; $form->attr('id+name', 'TypoSettings'); /* * Add inputfields */ $data = modules()->getConfig('TypoSettings'); foreach($inputfields as $key => $inputfield){ switch ($inputfield['type']){ case 'InputfieldTab': $tab = new InputfieldWrapper(); $tab->attr("title", $inputfield['label']); break; case 'InputfieldTabEnd': $form->append($tab); unset($tab); break; default: $field = modules()->get($inputfield['type']); $field->attr('id+name', $key); $field->label = $inputfield['label']; $field->required = $inputfield['required']; if(isset($inputfield['columnWidth'])){ $field->columnWidth = $inputfield['columnWidth']; } $field->value = (isset($data[$key]) ? $data[$key] : $inputfield['value']); $tab->append($field); } } /* * Add submit */ $submit = modules()->get("InputfieldSubmit"); $submit->attr("value", __("Save")); $submit->attr("id+name","submit"); $form->append($submit); /* * Process form */ if(input()->post->submit){ $data = modules()->getConfig('TypoSettings'); foreach($this->getDefaultData() as $key => $inputfield){ if($inputfield['type'] != 'InputfieldTab' && $inputfield['type'] != 'InputfieldTabEnd'){ if($inputfield['required'] && empty(input()->post->{$key})){ page()->error(sprintf(__('%1$s is a required field. (%2$s field was not updated)'), $inputfield['label'], $inputfield['label'])); }else{ $data[$key] = input()->post->{$key}; } } } modules()->saveConfig('TypoSettings', $data); page()->message($this->_('Saved Settings')); session()->redirect(page()->url); }else{ $out = $form->render(); } return $out; } const modulePage = 'settings'; const permissionView = 'setting-view'; const permissionEdit = 'setting-edit'; public function ___install(){ $page = $this->pages->get('template=admin,name='.self::modulePage); if (!$page->id) { $page = new Page(); $page->template = $this->templates->get('admin'); $page->parent = $this->pages->get($this->config->adminRootPageID); $page->title = 'Settings'; $page->name = self::modulePage; $page->process = $this; $page->save(); } $permissionView = $this->permissions->get(self::permissionView); if (!$permissionView->id){ $permissionView = new Permission(); $permissionView->name = self::permissionView; $permissionView->title = $this->_('View the general sitewide settings.'); $permissionView->save(); } $permissionEdit = $this->permissions->get(self::permissionEdit); if (!$permissionEdit->id){ $permissionEdit = new Permission(); $permissionEdit->name = self::permissionEdit; $permissionEdit->title = $this->_('Edit the general sitewide settings.'); $permissionEdit->save(); } } public function ___uninstall() { $page = $this->pages->get('template=admin, name='.self::modulePage); if ($page->id) { $page->delete(); } $permissionView = $this->permissions->get(self::permissionView); if ($permissionView->id){ $permissionView->delete(); } $permissionEdit = $this->permissions->get(self::permissionEdit); if ($permissionEdit->id){ $permissionEdit->delete(); } } }  
    • By AndZyk
      Hello,
      can somebody tell me, if it is possible to get the clear password of an InputfieldPassword inside a module, before it is encrypted?
      I have made a custom module which sets the password of an Auth0User after the hook publishReady with a random generated password. When I try to get a clear password from a InputfieldPassword in this hook, it is of course already encrypted (which is of course good). But is there a hook before the encryption, so I could get it one time to send it to Auth0?
      If there is not such thing, could be another possibility to add a jQuery script to get the value directly from the DOM and save it somewhere temporarily?
      I know this might be an unusual question, but I would appreciate any feedback. 
      Regards, Andreas
    • By Robin S
      Password Generator
      Adds a password generator to InputfieldPassword.

       
      Usage
      Install the Password Generator module.
      Now any InputfieldPassword has a password generation feature. The settings for the generator are taken automatically from the settings* of the password field.
      *Settings not supported by the generator:
      Complexify: but generated passwords should still satisfy complexify settings in the recommended range. Banned words: but the generated passwords are random strings so actual words are unlikely to occur.  
      https://github.com/Toutouwai/PasswordGenerator
    • By Slav
      Hey guys... Ok so I have a problem with a registration form password inputfield... The problem is that InputfieldPassword.js and InputfieldPassword.css are not loaded/fired. Or I dont even know exactly what is happening... Im pretty new to processwire and the website was not created by me so Im trying to figure out what has been done and how processwire works. Anyway this is how the form looks right now:

      ...and as you can see the styling is off (password validation check in particular)... this is what I see when page is loaded (without adding any input)... it looks like js and css files from wire/modules/Inputfield/InputfieldPassword are not firing... I dont know how it is supposed to work exactly so I dont even know where to start.
      Maybe someone has had similar problem and know an easy fix or can navigate me to what could cause this situation in PW.
      Oh by the way this problem occured when upgrading the PW version (current version 3.0.65)... everything else is ok... this is the only problem that has been found after upgrade...
      Appreciate all the help!
      Cheers!
    • By jen
      Yesterday we somehow lost access to all current admin, superuser/passwords to processwire.  We tried using the reset password form and nothing was sent.  We began noticing some of the menu buttons went missing as well as some photos.  Any suggestions how to resolve the login issue?