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 by in  Web Development   |  

2 Responses to symfony forms: hide created_at, updated_at columns

  1. Pingback: uberVU - social comments

  2. jq11 says:

    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

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>