Quick links: Content - sections - sub sections
EN FR
Quick Search Advanced search
 
Page

  [Opened] [[Résolu]] Utilisation de prepareDaoFromControls

Posted by ciblemedia on 11/28/2011 12:29

Bonjour à tous !

J'utilise jForms et dans ma fonction Save() je fais ceci :

function save() {
        $codecol = $this->param('c');
        
        if(empty($codecol)){
            $form = jForms::fill('colform');
        }else{
            $form = jForms::fill('colform',$codecol);
        }
        
        $verifform = true;
        if(!$form->check()){
            $verifform = false;
        }
        
        if(!$verifform){
            $rep = $this->getResponse('redirect');
            $rep->action="coll:show";
            return $rep;
        } else {
            // On contrôle les données saisies en fonction du type du collaborateur     
            $user = jAuth::getUserSession();
            
            $result = $form->prepareDaoFromControls('ficcol');
            $result['daorec']->codetie = $user->codetie;
            $result['daorec']->codeuge = $user->codeuge;
            $result['daorec']->codeuser = $codeuser;
            
            if($result['toInsert']) {
                $result['daorec']->codeusercre = $user->login;
                $result['daorec']->libusercre = $user->libuser;
                $result['dao']->insert($result['daorec']);
            } else {
                $result['daorec']->codeusermaj = $user->login;
                $result['daorec']->libusermaj = $user->libuser;
                $result['dao']->update($result['daorec']);
            }
       
            $rep = $this->getResponse('redirect');
            $rep->action="coll:end";
            if(!empty($codecol)){
                $rep->params = array('c' => $codecol);
            }
            return $rep;
        }
    }

Ce qui me pose problème, c'est $result['dao']->insert($result['daorec']); et $result['dao']->update($result['daorec']);. J'ai l'erreur suivante :

Error 500. A technical error has occured. Sorry for this trouble.

Pourtant j'ai le même code dans un autre module mais pour une autre table et ça fonctionne !

Je pensais que cela pouvait venir de ma DAO ou de mon formulaire mais je ne trouve pas...

Ci-dessous ma DAO :

<?xml version="1.0" encoding="UTF-8"?>
<dao xmlns="http://jelix.org/ns/dao/1.0">
    <datasources>
        <primarytable name="ficcol" realname="ficcol" primarykey="codecol" />
    </datasources>
    <record>
        <property name="codetie" fieldname="codetie" datatype="varchar" required="true" maxlength="20"/>
        <property name="codeuge" fieldname="codeuge" datatype="varchar" required="true" maxlength="20"/>
        <property name="typecol" fieldname="typecol" datatype="varchar" required="true" maxlength="20"/>
        <property name="codecol" fieldname="codecol" datatype="int" autoincrement="true"/>
        <property name="civilite" fieldname="civilite" datatype="varchar" required="true" maxlength="20"/>
        <property name="nom" fieldname="nom" datatype="varchar" required="true" maxlength="60"/>
        <property name="prenom" fieldname="prenom" datatype="varchar" required="true" maxlength="60"/>
        <property name="adr1" fieldname="adr1" datatype="varchar" default="" maxlength="60"/>
        <property name="adr2" fieldname="adr2" datatype="varchar" default="" maxlength="60"/>
        <property name="adr3" fieldname="adr3" datatype="varchar" default="" maxlength="60"/>
        <property name="adrcp" fieldname="adrcp" datatype="varchar" default="" maxlength="60"/>
        <property name="adrville" fieldname="adrville" datatype="varchar" default="" maxlength="60"/>
        <property name="adrpays" fieldname="adrpays" datatype="varchar" default="" maxlength="60"/>
        <property name="tel" fieldname="tel" datatype="varchar" default="" maxlength="20"/>
        <property name="mobile" fieldname="mobile" datatype="varchar" default="" maxlength="20"/>
        <property name="telaux" fieldname="telaux" datatype="varchar" default="" maxlength="20"/>
        <property name="email" fieldname="email" datatype="varchar" default="" maxlength="120"/>
        <property name="codeuser" fieldname="codeuser" datatype="varchar" required="true" maxlength="120"/>
        <property name="mdpuser" fieldname="mdpuser" datatype="varchar" default="" maxlength="50"/>
        <property name="datecre" fieldname="datecre" datatype="datetime" required="true" insertpattern="NOW()"/>
        <property name="codeusercre" fieldname="codeusercre" datatype="varchar" required="true" maxlength="20"/>
        <property name="libusercre" fieldname="libusercre" datatype="varchar" required="true" maxlength="60"/>
        <property name="datemaj" fieldname="datemaj" datatype="datetime" updatepattern="NOW()"/>
        <property name="codeusermaj" fieldname="codeusermaj" datatype="varchar" maxlength="20"/>
        <property name="libusermaj" fieldname="libusermaj" datatype="varchar" maxlength="60"/>
        
        <property name="identite" datatype="string" selectpattern="CONCAT(nom,', ',prenom)"/>
        <!--<property name="" fieldname="" datatype="string/int/float/date"
        required="yes" maxlength="" minlength="" regexp="" sequence=""
        updatepattern="" insertpattern="" selectpattern=""/>-->
    </record>
    <factory>
        <method name="listCol" type="select">
            <parameter name="codetie" />
            <parameter name="codeuge" />
            <conditions>
                <eq property="codetie" expr="$codetie" />
                <eq property="codeuge" expr="$codeuge" />
            </conditions>
        </method>
        <method name="getCol" type="selectfirst">
            <parameter name="codecol" />
            <conditions>
                <eq property="codecol" expr="$codecol" />
            </conditions>
        </method>
    </factory>
</dao>

Et voici mon formulaire :

<?xml version="1.0" encoding="utf-8"?>
<form xmlns="http://jelix.org/ns/forms/1.1">

<hidden ref="c" />

<menulist ref="typecol" required="true">
    <label>Type</label>
    <item value="UTILISATEUR">Utilisateur</item>
    <item value="CHAUFFEUR">Chauffeur</item>
    <hint>Le type de collaborateur est obligatoire.</hint>
</menulist>

<menulist ref="civilite" required="true">
    <label>Civilité</label>
    <item value="M.">Monsieur</item>
    <item value="MME">Madame</item>
    <item value="MLLE">Mademoiselle</item>
    <hint>La civilité est obligatoire.</hint>
</menulist>

<input ref="nom" required="true" maxlength="60">
	<label>Nom</label>
        <hint>Le nom est obligatoire.</hint>
</input>

<input ref="prenom" required="true" maxlength="60">
	<label>Prénom</label>
        <hint>Le prénom est obligatoire.</hint>
</input>

<input ref="adr1" maxlength="60">
	<label>Adresse 1</label>
</input>

<input ref="adr2" maxlength="60">
	<label>Adresse 2</label>
</input>

<input ref="adr3" maxlength="60">
	<label>Adresse 3</label>
</input>

<input ref="adrcp" maxlength="60">
	<label>Code Postal</label>
</input>

<input ref="adrville" maxlength="60">
	<label>Ville</label>
</input>

<input ref="tel" maxlength="20">
	<label>Téléphone</label>
        <help>(Ex: 0102030405)</help>
</input>

<input ref="mobile" maxlength="20">
	<label>Mobile</label>
</input>

<input ref="telaux" maxlength="20">
	<label>Autre téléphone</label>
</input>

<input ref="email" maxlength="120">
	<label>Email</label>
</input>

<submit ref="_submit">
	<label>Valider</label>
</submit>
</form>

D'avance merci !

Yann

  [Opened] Utilisation de prepareDaoFromControls

Reply #1 Posted by laurentj on 11/28/2011 12:58

Bonjour,

Error 500. A technical error has occured. Sorry for this trouble.

il faut aller voir dans les logs (tonappli/var/log), ou activer la debugbar si tu es en jelix 1.3. Tu auras alors la vraie erreur.

  [Opened] Utilisation de prepareDaoFromControls

Reply #2 Posted by ciblemedia on 11/28/2011 13:53

Bonjour,

Merci, je vais regarder les logs. Pour la debugbar, comment fait-on pour l'activer ?

  [Opened] Utilisation de prepareDaoFromControls

Reply #3 Posted by laurentj on 11/28/2011 16:21

C'est dans le manuel ;-)

 
Page
  1. [[Résolu]] Utilisation de prepareDaoFromControls