azralth Posted June 24, 2014 Share Posted June 24, 2014 (edited) Bonjour, Pour les besoin d'un client j'ai du ajouter deux champs dans le formulaire d'inscription Le problème c'est que je ne parviens pas à rendre ces champs non obligatoire. Je ne pense pas avoir oublié quelque chose. une copie de ma classe customer : les champs ajouté son "name_animal" et "birth_animal", à la fun du tableau. <?php class Customer extends CustomerCore { public $name_animal; public $birth_animal; /** * @see ObjectModel::$definition */ public static $definition = array( 'table' => 'customer', 'primary' => 'id_customer', 'fields' => array( 'secure_key' => array('type' => self::TYPE_STRING, 'validate' => 'isMd5', 'copy_post' => false), 'lastname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'required' => true, 'size' => 32), 'firstname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'required' => true, 'size' => 32), 'email' => array('type' => self::TYPE_STRING, 'validate' => 'isEmail', 'required' => true, 'size' => 128), 'passwd' => array('type' => self::TYPE_STRING, 'validate' => 'isPasswd', 'required' => true, 'size' => 32), 'last_passwd_gen' => array('type' => self::TYPE_STRING, 'copy_post' => false), 'id_gender' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'birthday' => array('type' => self::TYPE_DATE, 'validate' => 'isBirthDate'), 'newsletter' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 'newsletter_date_add' => array('type' => self::TYPE_DATE,'copy_post' => false), 'ip_registration_newsletter' => array('type' => self::TYPE_STRING, 'copy_post' => false), 'optin' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 'website' => array('type' => self::TYPE_STRING, 'validate' => 'isUrl'), 'company' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'), 'siret' => array('type' => self::TYPE_STRING, 'validate' => 'isSiret'), 'ape' => array('type' => self::TYPE_STRING, 'validate' => 'isApe'), 'outstanding_allow_amount' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat', 'copy_post' => false), 'show_public_prices' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'copy_post' => false), 'id_risk' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'copy_post' => false), 'max_payment_days' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'copy_post' => false), 'active' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'copy_post' => false), 'deleted' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'copy_post' => false), 'note' => array('type' => self::TYPE_HTML, 'validate' => 'isCleanHtml', 'size' => 65000, 'copy_post' => false), 'is_guest' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'copy_post' => false), 'id_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'copy_post' => false), 'id_shop_group' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'copy_post' => false), 'id_default_group' => array('type' => self::TYPE_INT, 'copy_post' => false), 'id_lang' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'copy_post' => false), 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false), 'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false), 'name_animal' => array('type' => self::TYPE_STRING,'validate' => 'isGenericName', 'required' => false), 'birth_animal' => array('type' => self::TYPE_STRING, 'validate' => 'isCleanHtml', 'required' => false), ), ); } Quand je tente de m'inscrire j'ai toujours l'erreur : Il y a 1 erreur une erreur s'est produite pendant la création de votre compte. Bref je sèche. Une idée de votre coté serait la bienvenue ! Merci. EDIT : J'ai trouvé ce qui coincé, pour ceux que ça intéresserait, il faut simplement passer la valeur à NULL pour ces champs dans la base de donnée. Edited June 24, 2014 by azralth (see edit history) Link to comment Share on other sites More sharing options...
Amokless Posted June 25, 2014 Share Posted June 25, 2014 (edited) Bonjour, Il me semble que "'required' => false" n'est pas nécessaire lorsque qu'un champ n'est pas obligatoire. Créer 2 lignes dans votre table SQL (par le biais de PHPMYSQL) portant le même nom que vos champs. Cordialement, Mathieu Edited June 25, 2014 by Amokless (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now