1
votes

I am using Symfony with propel to generate a form called BaseMeetingMeetingsForm.

In MeetingMeetingsForm.class.php I have the following configure method:

public function configure() {
    $this->useFields(array('name', 'group_id', 'location', 'start', 'length'));

    $this->widgetSchema['invited'] = new myWidgetFormTokenAutocompleter(array("url"=>"/user/json"));
}

In MeetingMeetings.php my save method is simply:

  public function save(PropelPDO $con = null) {
    $this->setOwnerId(Meeting::getUserId());

    return parent::save($con);
  }

However propel doesn't know about my custom field and as such doesn't do anything with it. Where and how to I put in a special section that can deal with this form field, please be aware it is not just a simple save to database, I need to deal with the input specially before it is input.

Thanks for your time and advice,

1
Please share the code where you read/process the form data. - hakre
There is none, symfony does it all somewhere, unless you know where? - Pez Cuckow
Okay, then that is the part you're missing. You need to process form data on your own if the standard processing by the abstraction does not everything you would love to get automatically. See symfony-project.org/jobeet/1_4/Propel/en/10 and scroll down for The Form Action. It should have the info you're looking for. - hakre

1 Answers

1
votes

You have to define a validator (and/or create your own). The validator clean() method returns the value that needs to be persisted.

In Doctrine (I don't know Propel) the form then calls the doUpdateObject() on the form, which in turns calls the fromArray($arr) function on the model.

So if it's already a property on your model you'll only need to create the validator. If it's a more complex widget, you'll need to add some logic to the form.