As a side note.... I didn't really want to use the  "nested" schemas
in my form because it creates complex form variable names, but I
didn't see another way I could import the "address" form/partial
without doing so.  So any input on how to connect the two forms would
be helpful too =]

thanks!

-- ian

On May 8, 4:47 pm, "Slick Rick" <[EMAIL PROTECTED]> wrote:
> So I'm trying to make forms with the new 1.1 framework, and have several 
> questions about the way it works.
>
> Here is my attempt to build a ClientForm:
>
> ------- BEGIN CODE --------
> <?php
> class ClientForm extends sfForm
> {
>   protected $client;
>
>   public function __construct($client, $defaults = null, $options = array(), 
> $CSRFSecret = null)
>   {
>     if (!$client instanceof Client)
>     {
>       throw new sfException('Object must be an instance of Client');
>     }
>
>     $this->client = $client;
>
>     parent::__construct($defaults, $options, $CSRFSecret);
>   }
>
>   public function configure()
>   {
>     $i18n = sfContext::getInstance()->getI18N();
>
>     $schema = new sfWidgetFormSchema(array(
>      'id' => new sfWidgetFormInputHidden(),
>      'general' => new sfWidgetFormSchema(array(
>        'name' => new sfWidgetFormInput(),
>        )),
>      'address' => new AddressFormSchema(), // AddressFormSchema extends 
> sfWidgetFormSchema
>      'additional' => new sfWidgetFormSchema(array(
>        'notes' => new sfWidgetFormTextarea(),
>        )),
>     ));
>
>     $schema->setLabels(array(
>       'general' => array(
>         'name' => $i18n->__('Name'),
>         'notes' => $i18n->__('Notes'),
>       )
>     ));
>
>     $schema->setHelps(array(
>       'general' => array(
>         'name' => $i18n->__('Enter a name for this client.'),
>         'notes' => $i18n->__('Enter any additional notes or profile 
> information.'),
>       )
>     ));    
>
>     $this->setWidgetSchema($schema);
>
>     $this->setValidatorSchema(
>      new sfValidatorSchema(array(
>        'name' => new sfValidatorString(array('min_length' => 2, 'max_length' 
> => 63)),
>      )));
>
>     $input = array(
>       'id'   => $this->client->id,
>       'general' => array(
>         'name' => $this->client->name,
>         ),
>      'additional' => array(
>        'notes' => $this->client->notes,
>        ),
>     );
>
>     $this->bind($input);
>   }
>
> }
>
> ------- END CODE --------
>
> Here are some issues/questions that I have:
>
> 1.) I don't think the Helps or the Labels work with my nested form schema 
> strucutre.  For instance, the labels just show the field name, not the actual 
> text that is defined. I don't receive an error or anything, so I assume I 
> have it setup right?
>
> 2.) The validator doesn't appear to work with the nested schema structure.  
> If i have it set to array('general' => array('name' => sfValidatorString())), 
> it can't find the "name" field.  
>
> 3.) Is I18N being handled the best way?  Seems like there might be a more 
> "integrated" approach?
>
> 4.) I am wondering if the way that I am importing the address schema is the 
> correct/best method to do this. Will it work recursively if I want to pass 
> data from the $client variable into the address schema?  Will validation 
> work?  Should I somehow include another sfForm instead of a schema?
>
> 5.) Any general tips/best practices that I might be overlooking to make this 
> the work the most seamless/flexible way?
>
> Thanks for any help or examples you can give me to get started in the right 
> direction.
>
> -- ian
--~--~---------~--~----~------------~-------~--~----~
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