[symfony-users] Re: Symfony 1.2 propel admin generator hide fields only in edit form

2009-08-28 Thread chakir ezziani
hi,
i think that you have only to change your generator.yml
edit:
 display: [descr, is_active]
new:
 display: [image, descr, is_active]

don't forget you have to clear the cache for the prod controller after
changin generator.yml
and verify the indentation

2009/8/27 José Nahuel Cuesta Luengo ncue...@cespi.unlp.edu.ar


 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

 Sid Bachtiar escribió:
  Hi all,
 
  I'm trying to understand the new admin generator for Symfony 1.2
 
  I have a field 'image', and I don't want people to edit it, only when
  inserting new record.
 
  Do I have to create separate form class for this?
 
 Sid,

  you can have inside the form the logic that decides whether or not to
 show the field:

  [php]
  // In your form's configure method
  // ...

  if ($this-isNew())
  {
$this-setWidget('image', new sfWidgetFormXXX());
$this-setValidator('image', new sfValidatorXXX());
  }
  else
  {
unset($this['image']);
  }

  // ...
  [/php]

 Hope this helps!

 Best regards

 - --
 José Nahuel Cuesta Luengo
 Desarrollo | CeSPI - UNLP
 ncue...@cespi.unlp.edu.ar
 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1.4.9 (GNU/Linux)
 Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

 iEYEARECAAYFAkqXCxQACgkQ2jTpOyePgAGrcQCeJmJTFac6YbPlT5cIPRxMB/Ah
 Am4AoIrDDmIJ8S2DlfCqnh8/FlJ2Sbr8
 =G3c6
 -END PGP SIGNATURE-

 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
symfony users group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~--~~~~--~~--~--~---



[symfony-users] Re: Symfony 1.2 propel admin generator hide fields only in edit form

2009-08-28 Thread Richtermeister

Hey Sid,

I would not rely on the generator.yml to configure which form fields
are displayed, since it only hides fields from the interface.. as far
as the form is concerned you end up with empty form fields if a field
is not displayed and the form is submitted.
As shown above the solution is to handle this inside the form class,
based on whether the object is new or not..

Hope this helps,
Daniel


On Aug 27, 4:36 pm, Sid Bachtiar sid.bacht...@gmail.com wrote:
 A bit more info, my schema:

   email_banner:
     id: { type: integer, primaryKey: true, autoIncrement: true }
     image: { type: varchar(255), required: true, unique: true }
     descr: { type: longvarchar }
     is_active: { type: boolean, required: true, default: true }
     created_at:

 When I edit, I want to only edit descr and is_active. I put this in
 the generator.yml:

 edit:
   display: [descr, is_active]

 I displayed correctly but would not save.

 On Fri, Aug 28, 2009 at 10:25 AM, Sid Bachtiarsid.bacht...@gmail.com wrote:
  Hi all,

  I'm trying to understand the new admin generator for Symfony 1.2

  I have a field 'image', and I don't want people to edit it, only when
  inserting new record.

  Do I have to create separate form class for this?

  --
  Blue Horn Ltd - System Development
 http://bluehorn.co.nz

 --
 Blue Horn Ltd - System Developmenthttp://bluehorn.co.nz
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
symfony users group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~--~~~~--~~--~--~---



[symfony-users] Re: Symfony 1.2 propel admin generator hide fields only in edit form

2009-08-27 Thread Sid Bachtiar

A bit more info, my schema:

  email_banner:
id: { type: integer, primaryKey: true, autoIncrement: true }
image: { type: varchar(255), required: true, unique: true }
descr: { type: longvarchar }
is_active: { type: boolean, required: true, default: true }
created_at:

When I edit, I want to only edit descr and is_active. I put this in
the generator.yml:

edit:
  display: [descr, is_active]

I displayed correctly but would not save.

On Fri, Aug 28, 2009 at 10:25 AM, Sid Bachtiarsid.bacht...@gmail.com wrote:
 Hi all,

 I'm trying to understand the new admin generator for Symfony 1.2

 I have a field 'image', and I don't want people to edit it, only when
 inserting new record.

 Do I have to create separate form class for this?

 --
 Blue Horn Ltd - System Development
 http://bluehorn.co.nz




-- 
Blue Horn Ltd - System Development
http://bluehorn.co.nz

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
symfony users group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~--~~~~--~~--~--~---



[symfony-users] Re: Symfony 1.2 propel admin generator hide fields only in edit form

2009-08-27 Thread José Nahuel Cuesta Luengo

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Sid Bachtiar escribió:
 Hi all,
 
 I'm trying to understand the new admin generator for Symfony 1.2
 
 I have a field 'image', and I don't want people to edit it, only when
 inserting new record.
 
 Do I have to create separate form class for this?
 
Sid,

  you can have inside the form the logic that decides whether or not to
show the field:

  [php]
  // In your form's configure method
  // ...

  if ($this-isNew())
  {
$this-setWidget('image', new sfWidgetFormXXX());
$this-setValidator('image', new sfValidatorXXX());
  }
  else
  {
unset($this['image']);
  }

  // ...
  [/php]

Hope this helps!

Best regards

- --
José Nahuel Cuesta Luengo
Desarrollo | CeSPI - UNLP
ncue...@cespi.unlp.edu.ar
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkqXCxQACgkQ2jTpOyePgAGrcQCeJmJTFac6YbPlT5cIPRxMB/Ah
Am4AoIrDDmIJ8S2DlfCqnh8/FlJ2Sbr8
=G3c6
-END PGP SIGNATURE-

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
symfony users group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~--~~~~--~~--~--~---