SUBSCRIBE VIA RSS


Subscribe to our feed

Symfony Experts

Symfony Experts
If you have an urgent question for a symfony-related issue, this is the place to ask.

Topics

TWITTER

Stack Overflow


The old fashioned way

RECENT TUNES

April 7, 2010 – 6:40pm symfony forms: hide created_at, updated_at columns

There are a few different methods you can use if you’d like to hide created_at and updated_at columns from your generated forms.

The first way, and the easiest, is to simply unset the fields in your form class:

class SampleForm extends BaseSampleForm
{   
  public function configure()
  {
    unset(
      $this['created_at'],
      $this['updated_at']
    );
  }
}

If you want the values to display in your form as read-only:

class SampleForm extends BaseSampleForm
{   
  public function configure()
  {
    $this->widgetSchema['created_at']    = new sfWidgetFormInput(array(), array('readonly'=>'readonly'));
    $this->widgetSchema['updated_at']    = new sfWidgetFormInput(array(), array('readonly'=>'readonly'));
  }
}
Posted in  Web Development   |     |  delicious  Digg

2 Responses to “symfony forms: hide created_at, updated_at columns”

  1. If you want to display plain text instead of input, you can create very simple widget:
    http://jq11.blogspot.com/2009/10/readonly-fields-in-symfony.html

    By jq11 on Apr 8, 2010

1 Trackback(s)

  1. Apr 7, 2010: uberVU - social comments

Post a Comment

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word