Reputation: 6612
I have created the form in Symfony 1.4/Doctrine) that is generated from the schema i can manipulate the field labels, the validation, modifying the widgets to get data from the db and can generate a new filed that is not in the schema.
The problem is the form is generated by $form variable and the the new field i create is at the bottom of this set of fields. How do i insert it somewhere in the schema generated fields.
Note . All i want to do is have Password and Confirm Password. Password is onviously in the schema but Confirm Password is not.
Upvotes: 2
Views: 1697
Reputation: 1920
You can use setPositions
from the WidgetSchema
to set positions of all your fields:
<?php
$this->getWidgetSchema()->setPositions(array(
0 => 'field_one',
1 => 'field_two',
// etc...
));
Or you can "move" a field across the form with moveField
:
<?php
// Moving to top
$this->getWidgetSchema()->moveField('field_one', sfWidgetFormSchema::FIRST);
// Moving before 'field_two'
$this->getWidgetSchema()->moveField('field_three', sfWidgetFormSchema::BEFORE, 'field_two');
// * Available actions are:
// *
// * sfWidgetFormSchema::BEFORE
// * sfWidgetFormSchema::AFTER
// * sfWidgetFormSchema::LAST
// * sfWidgetFormSchema::FIRST
Upvotes: 0
Reputation: 769
sfForm::useFields() is a new function to symfony 1.3 that allows the developer to specify exactly which fields the form should use and in which order they should be displayed. All other non-hidden fields are removed from the form.
from More With Forms Symfony 1.4
Upvotes: 2
Reputation: 1484
You can make any change by rendering each field separately in your template or view. For example, if you have user, password and confirm_password fields you can do:
//template or view
<?php echo $form['user']->renderRow()?><br/>
<?php echo $form['password']->renderRow()?><br/>
<?php echo $form['confirm_password']->renderRow()?>
if you want to do more complex things see Jobeet Form Example
Upvotes: 1