Can't use the editTpl

Discuss anything that's related to the Raxan framework

Can't use the editTpl

Postby seb7 » Mon Jun 27, 2011 10:06 am

Hi,

I'm very new to raxan.
As usual first steps often lead to big waste of time because of misunderstanding, so i request your help !

I'm trying to do something like the frulist example ( http://raxanpdi.com/sdk/examples/exampl ... d=editable ) but i can't edit the content.

Index.php
Code: Select all
<?php

require_once('raxan/pdi/autostart.php');

// controler
class EchoPage extends RaxanWebPage
{

    protected $bindopt; //template options

    protected function _config()
    {

        $this->masterTemplate = 'views/master.xhtml';
        // si on voulait utiliser un autre element html que celui de classe master-content on peut le specifier via :
        //$this->$masterContentBlock = '#page-content';
    }

    protected function _load()
    {
        $tplE = $this['#parties tr.edit'];
        $this->bindopt = array(
            'tplEdit' => $tplE->outerHtml(),
            'key' => 'id',
            'format' => array('date' => 'date:Y-m-d'),
    //        'edited' => 1
        );
        $tplE->remove();
    }

    protected function _prerender()
    {
        $db = $this->Raxan->connect('sqlite:db.sqlite');
        $dataset = $db->table('party_v');

        $this->parties->bind($dataset, $this->bindopt);
    }

    // déclaration de la vue utilisée
    protected function _init()
    {
        $this->appendView('parties.html');
    }

    protected function edit($e)
    {
        $v = $e->intVal();
        $this->bindopt['edited'] = $v;
    }

}

 


master.xhtml
Code: Select all
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
   <style type="text/css">
      .row {background-color:#aaf;}
      .row2 {background-color:#aff;}
   </style>
        <title>Parties</title>
    </head>

    <body>
      <h1>Parties</h1>
      <hr />
       <div class="master-content">

       </div>
      
    </body>
</html>


parties.html
Code: Select all
         
<table>
             <thead>
                <tr>
                   <th>id</th>
                   <th>titre</th>
                   <th>description</th>
                   <th>status</th>
                   <th>type</th>
                   <th>Organisateur</th>
                   <th>Date</th>
                   <th>Action</th>
                </tr>
             </thead>
             <tbody id="parties" xt-delegate="a.edit click, edit; a.save click,save, #parties input.editval;">

                <!-- ligne affichage -->
                <tr class="{ROWCLASS}" id="{party_id}">
               <td>{party_id}</td>
               <td>{title}</td>
               <td>{desc}</td>
               <td>{status}</td>
               <td>{type}</td>
               <td>{organisateur}</td>
               <td>{date}</td>
               <td>
                  <a class="edit" href="#{party_id}"  >Edit</a>
               </td>
                </tr>

                <!-- ligne modif -->
                <tr class="edit"  id="{party_id}">
               <td>{party_id}</td>
               <td><input type="text" value="{title}" name="title" /></td>
               <td>{desc}</td>
               <td>{status}</td>
               <td>{type}</td>
               <td>{organisateur}</td>
               <td>{date}</td>
               <td>
                  <input type="text" name="editval" class="editval"  value="{title}" />
                  <a class="save editval">Save</a>
               </td>
                </tr>
             </tbody>
          </table>


What's wrong ?
Attachments
myapp.zip
source
(2.88 KiB) Downloaded 271 times
seb7
 
Posts: 3
Joined: Mon Jun 27, 2011 9:56 am

Re: Can't use the editTpl

Postby seb7 » Mon Jun 27, 2011 12:54 pm

ok, finaly i got it.

I should use 'key' => 'party_id', in the bind options.
I thouight that 'id' was mean for the html to capture but that's the table key.
seb7
 
Posts: 3
Joined: Mon Jun 27, 2011 9:56 am

Re: Can't use the editTpl

Postby raymond » Tue Jun 28, 2011 2:55 am

Hi,

Welcome to the Raxan community.

I'm happy to hear that you have got to work. The "key" option must be set to the name of the table field to be used when selecting or editing rows.

See also Template options at http://raxanpdi.com/sdk/docs/templates.html

Best regards,
__
Raymond
raymond
Site Admin
 
Posts: 215
Joined: Tue Mar 17, 2009 5:04 am

Re: Can't use the editTpl

Postby seb7 » Tue Jun 28, 2011 7:44 am

Thanks Raymond.

I've read the doc more carefully to find the solution.

I'm not yet familiar with the Event Driven design, but i begin to think 'Raxan way' ... :)
seb7
 
Posts: 3
Joined: Mon Jun 27, 2011 9:56 am


Return to General Discussions

Who is online

Users browsing this forum: No registered users and 1 guest

cron