Hello,
first of all i'm using last SVN version of Symfony 1.4 .
I built a simple form extending sfFormSymfony and i'm experiencing an
unusual (or at least not documented) behavoir using sfWidgetFormSchema-
>setNameFormat() .
In the action/rendering i don't do anything expect creating the form
( new ProductSelectForm() ) and render it ( echo $form ) .
Here's the form code:
------- ProductSelectForm.class.php ------
class ProductSelectForm extends sfFormSymfony
{
public function configure()
{
parent::configure();
$this->widgetSchema->setNameFormat( 'test[%s]' );
// Build array with all products
$products = array( 'a', 'b' 'doesnt matter' );
$this->setWidget('product', new
sfWidgetFormChoice( array( 'choices' => $products ) ) );
$this->setValidator( 'product', new sfValidatorPass() );
}
}
------------------------- EOF --------------------
With the code above everything works fine and i get the rights names:
<select id="test_product" name="test[product]">
<input type="hidden" id="test__csrf_token"
value="bf84cffccc763f408c57dcc53f2c450f" name="test[_csrf_token]">
Now if i use setWidgets instead of setWidget
$this->setWidgets( array(
'product' => new sfWidgetFormChoice( array( 'choices' =>
$products ) )
));
i get:
<select id="test_product" name="product">
<input type="hidden" id="test__csrf_token"
value="bf84cffccc763f408c57dcc53f2c450f" name="_csrf_token">
and that's wrong.
After some testing i found that if i call the setNameFormat *after*
the setWidgets everything works right!
Can this be considered a bug or what else?
Online docs ( http://www.symfony-project.org/gentle-introduction/1_4/en/10-Forms
) doesn't say nothing about this and instead they have a error.
They say we can call setNameFormat as a method of sfForm ( $this-
>setNameFormat('contact[%s]'); ) . It looks to me wrong since it's a
sfWidgetFormSchema method and you can easily try it and see the method
not found error.
Can anyone confirm me these things?
I ask since last time i wrote to developers list reporting a still
existent (minor) bug i just got no reply at all. This just left me
alone thinking i was wrong.
Ettore Del Negro
--
If you want to report a vulnerability issue on symfony, please send it to
security at symfony-project.com
You received this message because you are subscribed to the Google
Groups "symfony users" 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-users?hl=en