示例#1
0
文件: dmForm.php 项目: jdart/diem
 public function setup()
 {
     parent::setup();
     $this->widgetSchema->setFormFormatterName('dmList');
     $this->key = 'dm_form_' . self::$counter++;
     $this->setName(dmString::underscore(get_class($this)));
 }
  /**
   * Constructor.
   *
   * @param string              $rootDir    The project root directory
   * @param sfEventDispatcher   $dispatcher The event dispatcher
   */
  public function __construct($rootDir = null, sfEventDispatcher $dispatcher = null)
  {
    if (null === self::$active || $this instanceof sfApplicationConfiguration)
    {
      self::$active = $this;
    }

    $this->rootDir = null === $rootDir ? self::guessRootDir() : realpath($rootDir);
    $this->symfonyLibDir = realpath(dirname(__FILE__).'/..');
    $this->dispatcher = null === $dispatcher ? new sfEventDispatcher() : $dispatcher;

    ini_set('magic_quotes_runtime', 'off');

    sfConfig::set('sf_symfony_lib_dir', $this->symfonyLibDir);

    $this->setRootDir($this->rootDir);

    // provide forms the dispatcher
    sfFormSymfony::setEventDispatcher($this->dispatcher);

    $this->setup();

    $this->loadPlugins();
    $this->setupPlugins();
  }
示例#3
0
 public function __construct($defaults = array(), $options = array(), $CSRFSecret = null)
 {
     parent::__construct($defaults, $options, $CSRFSecret);
     if ('mobile_frontend' === sfConfig::get('sf_app')) {
         $this->appendMobileInputMode();
     }
 }
 /**
  * Constructor.
  *
  * Notifies the 'form.post_configure' event.
  *
  * @see sfForm
  */
 public function __construct($defaults = array(), $options = array(), $CSRFSecret = null)
 {
     //SKeeping the sfFormDoctrine constructor (no object bound to this form)
     sfFormSymfony::__construct($defaults, $options, $CSRFSecret);
     if (self::$dispatcher) {
         self::$dispatcher->notify(new sfEvent($this, 'form.post_configure'));
     }
 }
示例#5
0
 public function __construct($defaults = array(), $options = array(), $CSRFSecret = null)
 {
     parent::__construct($defaults, $options, $CSRFSecret);
     $bootstrap_decorator = new sfWidgetFormSchemaFormatterBootstrap($this->getWidgetSchema(), $this->getValidatorSchema());
     $bootstrap_horizontal = new sfWidgetFormSchemaFormatterBootstrapHorizontal($this->getWidgetSchema(), $this->getValidatorSchema());
     $bootstrap_horizontal_short_label = new sfWidgetFormSchemaFormatterBootstrapHorizontalShortLabel($this->getWidgetSchema(), $this->getValidatorSchema());
     $this->getWidgetSchema()->addFormFormatter('bootstrap', $bootstrap_decorator);
     $this->getWidgetSchema()->addFormFormatter('bootstrap_horizontal', $bootstrap_horizontal);
     $this->getWidgetSchema()->addFormFormatter('bootstrap_horizontal_shortlabel', $bootstrap_horizontal_short_label);
     $this->setFormatter();
 }
示例#6
0
 public function setup()
 {
     parent::setup();
     foreach ($this->getWidgetSchema()->getFields() as $name => $widget) {
         $classname = get_class($widget);
         if ($classname == 'sfWidgetFormInputText') {
             if (($val = $this->getValidator($name)) && ($len = $val->getOption('max_length'))) {
                 $widget->setAttribute('maxlength', $len);
             }
         }
     }
 }
 public function bind(array $taintedValues = null, array $taintedFiles = null)
 {
     if (isset($taintedValues['field_action']) && is_array($taintedValues['field_action']) && count($taintedValues['field_action']) != 0 && in_array('related_files', $taintedValues['field_action']) && !isset($taintedValues['MassActionForm']['related_files'])) {
         $taintedValues['MassActionForm']['related_files']['visible'] = "";
         $taintedValues['MassActionForm']['related_files']['publishable'] = "";
     }
     if (isset($taintedValues['field_action']) && is_array($taintedValues['field_action']) && count($taintedValues['field_action']) != 0 && isset($taintedValues['MassActionForm']) && is_array($taintedValues['MassActionForm']) && count($taintedValues['MassActionForm']) != 0) {
         foreach ($taintedValues['field_action'] as $form_name) {
             $this->addSubForm($form_name);
         }
     }
     parent::bind($taintedValues, $taintedFiles);
 }
示例#8
0
 public function __construct($defaults = array(), $options = array(), $CSRFSecret = null)
 {
     parent::__construct($defaults, $options, $CSRFSecret);
 }
 /**
  * Sets the event dispatcher to be used by all forms.
  *
  * @param sfEventDispatcher $dispatcher
  */
 public static function setEventDispatcher(sfEventDispatcher $dispatcher = null)
 {
     self::$dispatcher = $dispatcher;
 }
示例#10
0
文件: dmForm.php 项目: vjousse/diem
 /**
  * Prevent loosing the widgetSchema name format.
  * 
  * @see sfForm#setWidgets($widgets)
  */
 public function setWidgets(array $widgets)
 {
     $return = parent::setWidgets($widgets);
     $this->setName($this->name);
     return $return;
 }
 public function getStylesheets()
 {
     if (!$this->getUseJqueryValidation()) {
         return parent::getStylesheets();
     }
     if (!$this->getJqueryValidationGenerator()->getRulesGenerated()) {
         $this->getJqueryValidationGenerator()->generateJavascript();
     }
     return array_merge($this->getJqueryValidationGenerator()->getStylesheets(), parent::getStylesheets());
 }
 /**
  * Automatically re-configure the form, and all embedded forms when the parent
  * form is bound. This allows you to change values on the client-side via 
  * Javascript, and still use the same form. 
  * 
  * @param array $taintedValues
  * @param array $taintedFiles
  * @see lib/vendor/symfony/lib/form/sfForm#bind($taintedValues, $taintedFiles)
  */
 public function bind(array $taintedValues = null, array $taintedFiles = null)
 {
     $this->configureWithValues($taintedValues, $taintedFiles);
     parent::bind($taintedValues, $taintedFiles);
 }
示例#13
0
    public function filter(sfEvent $event, $value)
    {
        $this->events[] = func_get_args();
        return $value;
    }
    public function reset()
    {
        $this->events = array();
    }
}
$listener = new FormListener();
$dispatcher = new sfEventDispatcher();
$dispatcher->connect('form.post_configure', array($listener, 'listen'));
$dispatcher->connect('form.filter_values', array($listener, 'filter'));
$dispatcher->connect('form.validation_error', array($listener, 'listen'));
sfFormSymfony::setEventDispatcher($dispatcher);
class TestForm extends sfFormSymfony
{
    public function configure()
    {
        $this->setValidators(array('first_name' => new sfValidatorString(), 'last_name' => new sfValidatorString()));
    }
}
// ->__construct()
$t->diag('->__construct()');
$listener->reset();
$form = new TestForm();
$t->is(count($listener->events), 1, '->__construct() notifies one event');
$t->is($listener->events[0][0]->getName(), 'form.post_configure', '->__construct() notifies the "form.post_configure" event');
// ->bind()
$t->diag('->bind()');
示例#14
0
 /**
  * (non-PHPdoc)
  * @see sfForm::embedFormForEach()
  * @return dmForm
  */
 public function embedFormForEach($name, sfForm $form, $n, $decorator = null, $innerDecorator = null, $options = array(), $attributes = array(), $labels = array())
 {
     parent::embedFormForEach($name, $this->setFormEmbedded($form), $n, $options, $attributes, $labels);
     return $this;
 }
 /**
  * Gets the JavaScript paths associated with the form.
  *
  * @see scr/www/application/lib/vendor/symfony/lib/form/sfForm#getJavaScripts()
  */
 public function getJavaScripts()
 {
   /*
   $this->formJavascripts = array(
     'jquery.min.js', //sfConfig::get('app_uniform_jquery'),
     'uni-form/uni-form.jquery.js' //sfConfig::get('app_uniform_styling'),
   );
   */
   return array_unique(array_merge($this->formJavascripts, parent::getJavaScripts()));
 }