levelx.me

  • Home
  • Design
    • Freebies
    • Inspiration
    • Tutorials
  • Technology
    • Benchmarks
    • How To
    • News
    • Programming
    • Reviews
  • Entertainment
    • Gaming
  • Life
    • Photography
    • Quotes
    • Self Improvement
  • Resources
    • Themes
    • Tools
    • Wallpapers
  • ETC
    • Do it Yourself
    • places
    • Uncategorized
  • Symfony 1.4 – Doctrine Timestampable Behaviour

    Recently Symfony released their LTS 1.4 branch. Unlike previous versions Symfony 1.4 comes with Doctrine as default ORM.  If you have worked with Doctrine’s you will be familiar with its Timestampable behavior.

    actAs:
      Timestampable: ~

    Timestampable behavior  automatically adds a created_at and updated_at column and automatically set the values when a record is inserted and updated.  I mostly use Symfony Admin Generator to generate Backend. This behavior worked fined till Symfony 1.2, but in Symfony 1.3 / 1.4 for unknown reasons this behavior adds created_at and updated_at fields as required and their value must be filled during creation of new record in admin generator.

    To fix this issue open your formClass located at

    lib/form/doctrine/yourClassForm.Class.php

    replace yourClass with actuall class name :) and add following code in configure function.

    public function configure()
    {
      //Following code will remove Required validators from these fields.
      unset($this->validatorSchema['created_at']);
      unset($this->validatorSchema['updated_at']);
    
      //following code will remove fields from form
      unset($this->widgetSchema['created_at']);
      unset($this->widgetSchema['updated_at']);
    }

    Hope this help

    Similar Posts

    • Symfony Admin Generator Calling Actions with Custom Parameters
    • Facebook for Android 1.3 Update
    • How Can Dawkins Explain the Perfect Eye in Our Brains?
    • IHATEBANKS
    • Pakistan Floods 2010 – How to Donate
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  

    Posted in: Programming

    8 Responses to “Symfony 1.4 – Doctrine Timestampable Behaviour”

    rdcklinux on February 13th, 2010 at 1:52 AM

    si ejecutas
    unset($this['created_at'],$this['updated_at']);

    hace exactamente lo mismo y es mas corto de escribir

    rdcklinux on February 13th, 2010 at 1:54 AM

    if you write
    unset($this['created_at'],$this['updated_at']);
    it is the same!!

    rdcklinux on February 13th, 2010 at 1:56 AM

    @rdcklinux
    in symfony 1.4

    Kryptic on February 13th, 2010 at 1:57 AM

    @rdcklinux
    Thanks for update :) but my code is more descriptive

    Jorge on February 17th, 2010 at 11:52 PM

    Y que sucede si lo que se desea es que aparezca el campo, por ejemplo el ID de una persona que es usado como llave primaria.

    Hasta donde he visto Symfony lo oculta automaticamente…
    cómo se debe configurar el Widget para que parezca?

    Muchas gracias por su ayuda.

    Kryptic on February 17th, 2010 at 11:59 PM

    @Jorge
    By admin por defecto de Symfony generados módulo muestra las claves principales. si no se muestran comprobar su archivo generator.yml
    config:
    list:
    display: [id,name,etc]

    Anton on April 25th, 2010 at 8:50 PM

    Hi Stig!
    Why you cant use more plain solution? Just pass “required => false” to these fields validators?

    $this->validatorSchema['created_at']->setOption(‘required’, false);
    $this->validatorSchema['updated_at']->setOption(‘required’, false);

    Samarone Lopes on August 6th, 2010 at 5:57 AM

    Better solution:

    abstract class BaseFormDoctrine extends sfFormDoctrine
    {
    public function setup()
    {
    unset($this->validatorSchema['created_at']);
    unset($this->validatorSchema['updated_at']);
    }
    }

    thanks for idea!

    Leave a Reply

    Categories

    • Benchmarks
    • Design
    • Do it Yourself
    • Entertainment
    • ETC
    • Freebies
    • Gaming
    • How To
    • Inspiration
    • Life
    • News
    • Photography
    • places
    • Programming
    • Quotes
    • Resources
    • Reviews
    • Self Improvement
    • Technology
    • Themes
    • Tools
    • Tutorials
    • Uncategorized
    • Wallpapers

    Explore us

    • deviantART
    • Flickr
    • oDesk
    • Picasa Album
    • Twitter
    • YouTube

    Friends

    • I Am The Stig
    • Stig Facts

    Recent Comments

    • ashwiniverma on Windows 7 Theme – VEER II
      please veer II help me you can understand my pain. my mom and dad is poor and not able to bay me a h... »
    • ashwiniverma on Windows 7 Theme – VEER II
      my internet speed is slow i am using relience net connect hi speed 1x modammodal no: AC8720my downlo... »
    • Jude Sleby on Calibrating HTC Desire Battery
      Looks like it worked »
    • B@D on Pakistan Floods 2010 – How to Donate
      @Aamir - Which area are you from? Where are you living these days? »
    • aamir on Pakistan Floods 2010 – How to Donate
      hy sir i am student of medical last year abroad in osh kirgyzctan.sir i am belonging to flooded effe... »
    • Older »
    levelx.me on Facebook

    Top Posts

    • FORMULA 1 - 2009 Season. (28)
    • Windows 7 Theme – VEER II (18)
    • M2N32 SLI-DLX WFI && RzR DeathADDER - - BURNT ! ! (17)
    • HTC Desire - Benchmark (17)
    • REQ: Stalker [ 1979 ] OST. (15)
    • Collaborations II - Sukhshinder Shinda feat. Rahat Fateh Ali Khan (14)
    • HP Pavilion dv6t Series Notebook PC (14)
    • Action Video Games Could Sharpen Eyesight (14)
    • Long March , The SIT-IN – 2009. (13)
    • Mobile OS wars: Symbian leads globally (13)

    levelx.me is proudly powered by WordPress | Theme Designed by AF8AB

    Valid CSS! Valid XHTML 1.0 Transitional