Question: All is in the title.

I get the URL param :

```
$log = $request->getParameter('logement');

```

Widget's statement :

```
$this->widgetSchema['logement'] = new sfWidgetFormInputText();

```

And I pass it in the form to prefill my widget 'logement' :

```
$this->form = new bailForm(array('logement' => $log));

```

I have read it in symfony's doc, but, when I do this, I have this error :

```
The "BailForm" form only accepts a "Bail" object.

```

I have already tried many things found on Internet but, no one works.

**EDIT**

The ORM is Doctrine
"Logement" is an attribute of "Bail" 

**EDIT 2**

I have tried :

```
$log = $request->getParameter('logement');

$this->form = new bailForm(null, array('logement' => $log));

```

I don't have error, but my widget "logement" isn't filled...

Answer: 
One of two ways:

**1. If you want to validate Logement**

```
$form = new BailForm(); //BailForm must have Logement validator set
$form->bind(array('logement' => $log) + $otherRequestParameters);
$form->updateObject(); //or save

```

**2. If you just want Logement set on the object**

```
$bail = new Bail();
$bail->Logement = $log;
$form = new BailForm($bail);

```
The forms that are auto-generated based on model classes (in this case, `BailForm` for `Bail`), are of type `sfFormObject`, and thus accept only parameters of type corresponding to the model class.

A naive solution is to declare a custom constructor for type `BailForm` that takes an array as a single parameter (or an array and an object of type Bail).

This would not be very good practice however, as model forms are designed to work with model classes only. This `logement` parameter - what is its significance with respect to the `Bail` object? Maybe if you ask yourself that question, you can come up with a more suitable design that probably incorporates the `logement` as an attribute of `Bail`.