예제 #1
0
 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());
         }
     }
 }
예제 #2
0
파일: dmContext.php 프로젝트: rafix/diem
 /**
  * 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'))))));
 }
예제 #4
0
 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'))))));
 }
예제 #5
0
 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();
 }
예제 #6
0
 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']);
     }
 }
예제 #7
0
 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;
 }
예제 #9
0
 /**
  * @see sfForm
  */
 public function __construct(dmAdminPageMetaView $metaView, $options = array(), $CSRFSecret = null)
 {
     $this->metaView = $metaView;
     return parent::__construct(array(), $options, $CSRFSecret);
 }
예제 #10
0
 protected function getSearchForm()
 {
     $form = new dmForm();
     return $form->setName('search')->setWidgets(array('query' => new sfWidgetFormInputText()))->setValidators(array('query' => new sfValidatorString()));
 }
예제 #11
0
파일: dmForm.php 프로젝트: vjousse/diem
 /**
  * Sets the service container to be used by all forms.
  *
  * @param dmBaseServiceContainer $serviceContainer
  */
 public static function setServiceContainer(dmBaseServiceContainer $serviceContainer)
 {
     self::$serviceContainer = $serviceContainer;
 }
예제 #12
0
 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();
 }