This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use the new forum.
Home » support » General discussion » created_at with datasystem
created_at with datasystem [message #97103] Sat, 10 April 2010 21:38 Go to next message
matz  is currently offline matz
Messages: 32
Registered: March 2010
Member
hi..i have a object news and when i create this object i want the created_at field take the date system automatically.

can anyone help me to do this??
Re: created_at with datasystem [message #97110 is a reply to message #97103 ] Sun, 11 April 2010 01:52 Go to previous messageGo to next message
janismucenieks  is currently offline janismucenieks
Messages: 31
Registered: March 2010
Location: Latvia
Member
Hi!

I think what You are looking for is here: http://www.symfony-project.org/jobeet/1_4/Doctrine/en/06

Search for: Object Serialization (3rd paragraph from top)

Does it help?
Re: created_at with datasystem [message #97126 is a reply to message #97103 ] Sun, 11 April 2010 16:23 Go to previous messageGo to next message
matz  is currently offline matz
Messages: 32
Registered: March 2010
Member
janismucenieks i follow these example and i do this

class siteNoticia extends BasesiteNoticia
{
	public function save(Doctrine_Connection $conn = null)
	{
		if ($this->isNew())
		{
		  $this->setCreatedAt(date('Y-m-d H:i:s'));
		}

		return parent::save($conn);
	}

}


however when i create my noticia i couldn't do it because apears "Required." on created_at field.
i create the noticia in the backend.
Re: created_at with datasystem [message #97127 is a reply to message #97126 ] Sun, 11 April 2010 16:28 Go to previous messageGo to next message
janismucenieks  is currently offline janismucenieks
Messages: 31
Registered: March 2010
Location: Latvia
Member
I think You're missing this part " time() "
Try this way.

class siteNoticia extends BasesiteNoticia
{
	public function save(Doctrine_Connection $conn = null)
	{
		if ($this->isNew())
		{
		  $this->setCreatedAt(date('Y-m-d H:i:s', time()));
		}

		return parent::save($conn);
	}

}
Re: created_at with datasystem [message #97128 is a reply to message #97103 ] Sun, 11 April 2010 16:34 Go to previous messageGo to next message
matz  is currently offline matz
Messages: 32
Registered: March 2010
Member
janismucenieks i do that but it apears "Required." on created_at field again and don't create and insert the object on database.
Re: created_at with datasystem [message #97129 is a reply to message #97128 ] Sun, 11 April 2010 16:45 Go to previous messageGo to next message
janismucenieks  is currently offline janismucenieks
Messages: 31
Registered: March 2010
Location: Latvia
Member
Ok. You also need to unset that field from form.

In lib\form\doctrine\siteNoticiaForm.class.php
Put this in:

public function configure()
  {
	unset(
        $this['created_at']
    );	
  }


You can find more on this here: http://www.symfony-project.org/jobeet/1_4/Doctrine/en/10
searach for: Customizing the Job Form
icon14.gif  Re: created_at with datasystem [message #97131 is a reply to message #97103 ] Sun, 11 April 2010 16:52 Go to previous message
matz  is currently offline matz
Messages: 32
Registered: March 2010
Member
janismucenieks it works!!!

thanks a lot!!! Thumbs Up
Previous Topic:Need simple sample for doctrine
Next Topic:Newbie: Using without database
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software