public function setup() { parent::setup(); // Don't allow editing of slug if we're dealing with an already existing site/application if (!$this->isNew()) { unset($this['slug']); } }
public function setup() { parent::setup(); // site slug is used to generate symfony app // but symfony restricts allowed characters for app name if ($this->isNew()) { $this->setValidator('slug', new sfValidatorAnd(array($this->getValidator('slug'), new sfValidatorRegex(array('pattern' => '/^[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*$/'), array('invalid' => 'Site slug must consist of only letters, digits and underscores. ' . 'It also must not start with digit.'))), array('required' => $this->getValidator('slug')->getOption('required')))); } else { $this->getWidget('slug')->setAttribute('readonly', 'readonly'); $this->setValidator('slug', new sfValidatorChoice(array('choices' => array($this->getObject()->getSlug())))); } $field = sfApplicationConfiguration::getActive()->getPluginConfiguration('sfThemePlugin')->getThemeToolkit()->getThemeWidgetAndValidator(); $this->widgetSchema['theme'] = $field['widget']; $this->validatorSchema['theme'] = $field['validator']; }