Skip to content

Instantly share code, notes, and snippets.

@eminetto
Created June 24, 2011 19:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eminetto/1045552 to your computer and use it in GitHub Desktop.
Save eminetto/1045552 to your computer and use it in GitHub Desktop.
<?php
class UsersController extends Zend_Controller_Scaffolding {
public function init() {
parent::init();
//configuração dos campos a serem mostrados
$fields = array (
'name' => array (
'title' => 'Nome',
'required' => true,
'filters' => array('StripTags'),
'skip' => false,
'searchable' => true,
'sortable' => true,
'sortBy' => 'asc',
),
'email' => array (
'title' => 'E-mail',
'required' => true,
'filters' => array('StripTags'),
'validators' => array('emailAddress'),
'skip' => false,
'sortable' => true,
'sortBy' => 'desc',
'searchable' => true
),
'password' => array (
'title' => 'Senha',
'required' => true,
'type' => 'password',
'filters' => array('StripTags'),
'skip' => 'list',
'sortBy' => 'desc',
//antes de salvar o campo ele vai executar esse método
'saveModifier' => 'Admin_UsersController::password',
),
'status' => array(
'title' => 'Situação',
'type' => 'select',
'skip' => false,
'sortable' => true,
'searchable' => true
),
'role' => array(
'title' => 'Permissões',
'type' => 'select',
'skip' => 'list'
),
);
$options = array(
'entityTitle' => 'Usuários',
'pagination' => true,
'csrfProtected' => false,
);
//cria o scaffolding passando o Model e as configurações
$this->initScaffolding(new Users(), $fields, $options);
}
/**
* gera o hash da senha
*
* @return void
* @author Elton Minetto
**/
static public function password($val) {
return md5($val);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment