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 - 343 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 

Commentaires sur ce snippet

gravatar icon
#1 replica watches le 2010-03-04 at 02:41

This looks awesome! Thank you for your information!

gravatar icon
#2 replica watches le 2010-03-04 at 02:51

Interesting thing! That's awesome! I can't wait to get into it. This looks awesome! Thank you for your information!

gravatar icon
#3 replica watches le 2010-03-04 at 03:35

This looks awesome! Thank you for your information!

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