Distinct backend Filters for users

Simple way of showing different backend filters for different users:


class YourFormFilter extends BaseYourFormFilter {
public function setup() {
// ...

$context = sfContext::getInstance(); /* @var $context sfContext */
$request = $context->getRequest(); /* @var $request sfWebRequest */
$user = $context->getUser(); /* @var $user sfBasicSecurityUser */

if ($user->hasCredential('credential_to_check')) {
$this->setWidget('your_field', new sfWidgetFormFilterInput());
$this->setValidator('your_field', new sfValidatorPass(array('required' => false)));
$this->widgetSchema->moveField('your_field', sfWidgetFormSchema::AFTER, 'other_field'); // this is good to re-arrange the filters order

// ...

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>