0

I'd like to use forms generated by propel

( propel:generate-module --with-show --non-verbose-templates frontend user users )

but I'd like do modify them a little bit. e.q. I'd like to remove fields that are foreign keys. Is it possible, or do I have to create my own forms?

EDIT

in file: project_name/lib/form/form_file.class.php there is an empty class which derives from some base class. If put there something like this:

$this->setWidgets(array(
      'name'    => new sfWidgetFormInput()
));

All the default fields disappear and there is only this 'name' field in the form, which is not what I'm looking for.

0

2 Answers 2

1

If you are using admin generator as you indicated, you can edit your forms via a generator.yml file. With this file you can do any number of things include set which widgets you want to appear, order of entry, actions, etc.

The generator.yml file is located in /apps/app_name/modules/module_name/config

You can read more about it in the symfony docs.

-- Edit --

If you are not using the generator.yml file, you can edit the form class directly, read this article relating to symfony forms for more info.

Example widget manipulation:

//-----
//Remove Unwanted
//-----
unset(
    $this['created_at'],
    $this['updated_at'],
    $this['ingredient_list'] //Will be embedded due to extra meta data
);
//-----

// Add a select menu using model to populate values
$this->widgetSchema['state_list'] = new sfWidgetFormPropelChoice(array('model' => 'State', 'multiple' => true, 'order_by' => array('name', 'asc')));

// Add matching validator
$this->validatorSchema['state_list'] = new sfValidatorPropelChoice(array('model' => 'State', 'column' => 'id', 'multiple' => true));

// I can also force widget presentation order
$this->getWidgetSchema()->moveField('country_list', sfWidgetFormSchema::AFTER, 'state_list');

// You can also add a callback function when the form is submitted
$this->validatorSchema->setPostValidator(
    new sfValidatorCallback(array('callback' => array($this, 'dupeCheck')))
);
Sign up to request clarification or add additional context in comments.

3 Comments

I'm not sure what I'm using (I'm really new to symfony) but there is no config directory on the path you suggested. I found project_name/lib/form/form_file.class.php which contains an empty class for form. Details added to the question.
@gisek: Looks like you are using symfony 2, you can tell if you add _dev to your controller, there will be a dev bar that shows up with the version number, http://yourdomain.com/yourapp_dev/.
It's said there: Debug toolbar 1.4.8
0

If you're not using admin generator, you can just edit the templates generated in the folder /app/modulename/templates/.

For example, modify the indexSuccess.php file contained in that folder to change the structure/info of the table created which by default will display all the info that exists in your DB table.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.