Créer un compte ou loggez-vous pour pouvoir ajouter, commenter et noter les snippets.

Navigation

my Symfony Plugins

Plugins demos


My bookmarks

Vous pouvez commenter/noter en utilisant le compte anonymous (mot de passe: anonymous)
You can comment/rate using the anonymous account (password: anonymous).

[Symfony 1.2] Form white list function - 772 view(s)

Allow to remove all fields of a form except a given list:

public function unsetAllExcept($fields = array())
{
  foreach($this->getObject()->toArray(BasePeer::TYPE_FIELDNAME) as $key => $val)
  {
    $tmp[] = strtolower($key);
  }
 
  $tmp = array_diff($tmp, $fields);
 
  foreach($tmp as $value)
  {
    unset($this[$value]);
  }
}

Remove created_at, updated_at ...

$this->unsetAllExcept(array('comment'));
par COil le 2009-08-13, taggé : form  security  symfony 

Ajouter un commentaire / Add a comment

Nom / Pseudo : 

Email (gravatar activé/activated) : 

Site Web (facultatif/optional) : 

Commentaire / Comment : (*)

Ecrivez le mot "vache" ci dessous. (Write the word "vache" below) (*)

Debug toolbar