unexpected extra form field named

You had an unbound input in your form and Symfony throw you an “unexpected extra form field named ‘yourfield'” error ?

Don’t worry, add a sfValitorPass() in your form description :

1
2
3
4
5
6
class DemandeForm extends BaseDemandeForm
{
   public function configure()
   {
        $this->validatorSchema['yourfield'] = new sfValidatorPass();
   }

fpdf add page number

Here an easy way to add page number at the end of a fpdf document

In your fpdf class, before calling addpage(), call the AliasNbPages() fonction

1
$this->AliasNbPages();

then create a footer() fonction to override the default empty footer

1
2
3
4
5
6
7
8
function Footer()
{
        $this->SetY(-10);
        $this->SetFont('Arial', '', 8);
        $this->Cell(0,10,'Page '.$this->PageNo().'/{nb}', 0, 0, 'C');
        $this->SetY(-10);
        $this->Cell(0,10,"date d'impression: ".date('d/m/Y'), 0, 0, 'R');
}

The complete class : file pdfListeDemandes.class.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php
 
class pdfListeDemandes extends FPDF
{
   function init()
   {
                $this->AliasNbPages();
                ...
   }
   function writeListe()
   {
         $this->init();
         ...
   }
 
   function Footer()
   {
        $this->SetY(-10);
        $this->SetFont('Arial', '', 8);
        $this->Cell(0,10,'Page '.$this->PageNo().'/{nb}', 0, 0, 'C');
        $this->SetY(-10);
        $this->Cell(0,10,"date d'impression: ".date('d/m/Y'), 0, 0, 'R');
   }
 
}

And the code to call your class

1
2
3
4
$pdf = new pdfListeDemandes();
$pdf->writeListe();
$pdf->output('Liste_demande.pdf', 'D');
exit;

Symfony 1.4 format date doctrine object

To format a date from a doctrine object, you can use this code, quick and easy.

1
$demande->getDateTimeObject('date_creation')->format('d/m/Y');

Sometimes, this first solution return current date even if the doctrine record is null.
You then have to use this other solution

1
2
use_helper('Date');
format_date($demande->getDateCreation(), 'dd-MM-yyyy');

You can found format rules here