⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Password verification field



jorisvt
  • profile picture
  • Member

Posted 05 April 2012 - 08:24 AM

Hi, I want to add an password verifcation field, but it shows as a normal text field on the add/edit view. I also want to clear the orginial password field on add/edit actions. But I can't get it to work.



$this->ag_auth->restrict('admin');

$crud = new grocery_CRUD();

$crud->set_table('tblusers')
->set_subject('Users')
->columns('usrName','usrFullName','usrGender','usrPassword','usrEmail','usrCompany','usrFunction')
->fields('usrName','usrFullName','usrPassword','usrGender','verification','usrEmail','usrCompany','usrFunction')

->change_field_type('usrPassword','password')

//display fieldname, shown text
->display_as('usrId','ID')
->display_as('usrName','Username')
->display_as('usrFullName','Full name')
->display_as('usrGender','Gender')
->display_as('usrPassword','Password')
->display_as('usrEmail','Email')
->display_as('usrCompany','Company')
->display_as('usrFunction','Function')

//validation
->set_rules('usrName', 'Username', 'required|min_length[5]|max_length[30]')
->set_rules('usrFullName', 'Full name', 'required|min_length[5]|max_length[80]')
->set_rules('usrGender', 'Gender', 'required|min_length[1]|max_length[1]')
->set_rules('usrPassword', 'Password', 'required|min_length[6]|max_length[32]');

$crud->change_field_type('grpCompId', 'hidden', companyId());

$crud->set_relation('usrCompany','tblCompanies','compName');

$this->grocery_crud->callback_field('verification','verificationField');

$this->grocery_crud->callback_column('usrPassword',array($this,'emptyField'));

$output = $crud->render();
$this->_example_output($output);

function verificationField()
{
return '+30 <input type="password" maxlength="50" value="" name="pasVer" style="width:462px">';
}

function emptyField($value,$row)
{
return '';
}

xxaxxo
  • profile picture
  • Member

Posted 06 April 2012 - 08:25 AM

+1 for your effort, i'm working on something similar, i'd like to limit the add/edit function by user.
Example I have a news database with categories
user "auto" - can modify the news in category auto.
when you edit - the link is: /crud/news/edit/{id} , if you manually enter another id at the end of the link - you get the info and you can edit it too.
I'd like to make a check if the proper user is editing then do the edit. IF you manage to find a solution for your password problem , please post it here, i'll do the same if I find it first =)

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 06 April 2012 - 13:59 PM

I found where your problem is:

This is wrong:

$this->grocery_crud->callback_field('verification','verificationField');

$this->grocery_crud->callback_column('usrPassword',array($this,'emptyField'));


The right thing is to write:


$crud->callback_field('verification','verificationField');

$crud->callback_column('usrPassword',array($this,'emptyField'));