protected function prepareFormForPage(dmForm $form) { if (!($page = $this->serviceContainer->getParameter('context.page'))) { return $form; } if (!($pageRecord = $page->getRecord())) { return $form; } foreach ($form->getWidgetSchema()->getFields() as $widgetKey => $widget) { $widgetModel = $widget->getOption('model'); if ($widget instanceof sfWidgetFormDoctrineChoice && $pageRecord instanceof $widgetModel) { $form->changeToHidden($widgetKey)->setDefault($widgetKey, $pageRecord->getPrimaryKey()); } } }
/** * Initializes the current dmContext instance. * * @param dmApplicationConfiguration $configuration An dmApplicationConfiguration instance */ public function initialize(sfApplicationConfiguration $configuration) { $this->checkProjectIsSetup(); parent::initialize($configuration); sfConfig::set('dm_debug', $this->getRequest()->getParameter('dm_debug', false)); // load the service container instance $this->loadServiceContainer(); // configure the service container with its required dependencies $this->configureServiceContainer($this->serviceContainer); if (method_exists($this->configuration, 'configureServiceContainer')) { $this->configuration->configureServiceContainer($this->serviceContainer); } // connect the service container and its services to the event dispatcher $this->serviceContainer->connect(); /* * dmForm requires service container... */ dmForm::setServiceContainer($this->serviceContainer); /* * some classes needs the event dispatcher to communicate * and the service container... */ dmDoctrineQuery::setModuleManager($this->getModuleManager()); dmDoctrineTable::setServiceContainer($this->serviceContainer); $this->helper = $this->serviceContainer->getService('helper'); // notify that context is ready $this->dispatcher->notify(new sfEvent($this, 'dm.context.loaded')); }
public function configure() { parent::configure(); $this->widgetSchema['name'] = new sfWidgetFormInputText(); $this->validatorSchema['name'] = new dmValidatorDirectoryName(); $this->mergePostValidator(new sfValidatorAnd(array(new sfValidatorCallback(array('callback' => array($this, 'checkExistsInParent')))))); }
public function configure() { parent::configure(); $parentChoices = $this->getParentChoices(); $this->widgetSchema['parent_id'] = new sfWidgetFormChoice(array('choices' => $parentChoices)); $this->validatorSchema['parent_id'] = new sfValidatorChoice(array('choices' => array_keys($parentChoices), 'required' => true)); $this->mergePostValidator(new sfValidatorAnd(array(new sfValidatorCallback(array('callback' => array($this, 'checkExistsInParent')))))); }
public function configure() { parent::configure(); $this->widgetSchema['file'] = new sfWidgetFormDmInputFile(); $this->widgetSchema['override'] = new sfWidgetFormInputCheckbox(); $this->widgetSchema['override']->setLabel('Override?'); $this->validatorSchema['file'] = new sfValidatorFile(array()); $this->validatorSchema['override'] = new sfValidatorBoolean(); }
public function configure() { parent::configure(); $this->widgetSchema['cssClass'] = new sfWidgetFormInputText(array('label' => 'CSS class')); $this->validatorSchema['cssClass'] = new dmValidatorCssClasses(array('required' => false)); $this->setDefault('cssClass', $this->dmWidget->get('css_class')); /* * if the user can not edit widgets (but only fast edit them) * remove the CSS class field */ if (($user = $this->getService('user')) && !$user->can('widget_edit')) { $this->changeToHidden('cssClass'); $this->widgetSchema['cssClass']->setAttribute('readonly', true); //unset($this['cssClass']); } }
public function __construct(dmDoctrineRecord $record = null) { $this->record = $record; parent::__construct(); }
public function getDefaults() { $defaults = $this->getDefaultsFromLastUpdated(); if (count($defaults) > 0) { return $defaults; } $defaults = $this->getFirstDefaults(); if (count($defaults) > 0) { return $defaults; } $defaults = parent::getDefaults(); unset($defaults['dm_behavior_enabled']); return $defaults; }
/** * @see sfForm */ public function __construct(dmAdminPageMetaView $metaView, $options = array(), $CSRFSecret = null) { $this->metaView = $metaView; return parent::__construct(array(), $options, $CSRFSecret); }
protected function getSearchForm() { $form = new dmForm(); return $form->setName('search')->setWidgets(array('query' => new sfWidgetFormInputText()))->setValidators(array('query' => new sfValidatorString())); }
/** * Sets the service container to be used by all forms. * * @param dmBaseServiceContainer $serviceContainer */ public static function setServiceContainer(dmBaseServiceContainer $serviceContainer) { self::$serviceContainer = $serviceContainer; }
public function __construct(DmUser $user, array $options = array()) { $this->user = $user; parent::__construct(array(), $options); }
public function configure() { parent::configure(); $this->widgetSchema['behaviors'] = new sfWidgetFormInputHidden(); $this->validatorSchema['behaviors'] = new sfValidatorPass(); }