Skip to content

Instantly share code, notes, and snippets.

@chtitux
Created August 24, 2010 13:32
Show Gist options
  • Save chtitux/547555 to your computer and use it in GitHub Desktop.
Save chtitux/547555 to your computer and use it in GitHub Desktop.
<?php
/**
* Etudiant form.
*
* @package trombinoscope
* @subpackage form
* @author T. Helleboid <t.helleboid@iariss.fr>
* @version SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
*/
class EtudiantForm extends BaseEtudiantForm
{
public function configure()
{
unset(
$this['created_at'],
$this['updated_at'],
$this["code"],
$this['visites'],
$this['slug'],
$this['facebook_uid'],
$this['filiere_id'],
$this['promotion_id'],
$this['nom'],
$this['prenom']
);
$this->widgetSchema['photo'] = new sfWidgetFormInputFile(array('label' => 'Photo'));
$this->validatorSchema['photo'] = new sfValidatorFile(array(
'required' => false,
'path' => sfConfig::get('sf_upload_dir').'/etudiants',
'mime_types' => 'web_images',
));
$this->widgetSchema['sexe'] = new sfWidgetFormChoice(array(
'choices' => Doctrine::getTable('Etudiant')->getSexes(),
'expanded' => true,
));
$this->widgetSchema['promotion_id'] = new sfWidgetFormDoctrineChoice(array(
"expanded" => true,
"model" => 'Promotion',
));
// $this->validatorSchema['email'] = new sfValidatorEmail();
$this->widgetSchema['date_naissance'] = new sfWidgetFormI18nDate(array(
'culture' => 'fr',
'years' => array_combine(range(1980, date('Y')-10),range(1980, date('Y')-10)),
));
$this->widgetSchema['parrain_id'] = new sfWidgetFormDoctrineChoice(array(
'model' => $this->getRelatedModelName('Parrain'),
'add_empty' => true,
'order_by' => array("Nom", "asc")));
}
public function processValues($values) {
// Évite de modifier la promo
// $values['code'] = $request->getNom();
unset($values['filiere_id'], $values['promotion_id'], $values['prenom'], $values['nom']);
$values['code'] = "yeah";
// $values['nom'] = Trombinoscope::firstUpperCase($values['nom']);
// $values['prenom'] = Trombinoscope::firstUpperCase($values['prenom']);
$values['tel_mobile'] = implode('.',str_split(str_replace(array('.',' ','-'), '', $values['tel_mobile']),2));
return parent::processValues($values);
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment