On May 14, 1:00 am, "Slick Rick" <[EMAIL PROTECTED]> wrote:
> Does anyone know if there is there a way to define a "default" form schema 
> formatter in 1.1 without having to manually declare it in every form?
>

I extended the sfDoctrineFormGenerator and modified the
sfDoctrineFormGeneratedTemplate (= myDoctrineFormGeneratedTemplate):

public function setup()
  {
    $this->setWidgets(array(
...
    ));

    $this->setValidators(array(
...
    ));

    $this->widgetSchema->setNameFormat('<?php echo $this-
>underscore($this->modelName) ?>[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this-
>validatorSchema);

    $formatter = new myWidgetFormSchemaFormatterList($this-
>widgetSchema);
    $this->widgetSchema->addFormFormatter('custom', $formatter);
    $this->widgetSchema->setFormFormatterName('custom');

    parent::setup();
  }

That way I can switch the formatters of all forms with one
doctrine:build-forms-custom call. You can also add other useful
functions in there. I added one function disable() to disable a
complete form:

public function disable()
  {
    foreach ($this->widgetSchema->getFields() as $widget) {
      if (!$widget->isHidden()) {
        $widget->setAttribute('disabled', 'disable');
      }
    }
  }

Other Suggestions?

Thomas
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/symfony-devs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to