Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7799721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T00:24:15+00:00 2026-06-02T00:24:15+00:00

I have a table, TableModule , with 2 foreign keys, let’s say fk1 and

  • 0

I have a table, TableModule, with 2 foreign keys, let’s say fk1 and fk2.

  • fk1 goes to pk1 in table Table 1

  • fk2 goes to pk2 in table Table 2

I created a module. let’s say, Module, which uses the TableModule (the one with the fk’s)

I want to create 4 filters for those fk: 2 input text and 2 dropdowns. In particular, I want to create two filters per fk. This is:

For fk1 I would get:
  -InputText
  -Dropdown (choice in propel) 
For fk2 I would get:
  -InputText
  -Dropdown (choice in propel)

Of course, this would show the results of Table1 and Table2.

Now, in my config.yml I got:

    ...
    filter:
      display: [fk1, fk1TextFilter, fk2, fk2TextFilter]
    ...  

This is: fk1 and fk2 would be filtered as dropdowns, The partials fk1TextFilter and fk2TextFilter must be customized for filtering using a text input.

Why I created those partials? Because I can’t duplicate the fk in the config.yml!!

In lib/filter/table1/ModuleFormFilter I did (notice that is in table1):

 public function configure()
 {
  $this->setWidgets(array(
  'fk1'                => new sfWidgetFormPropelChoice(array('model' => 'table1',  'add_empty' => true,)),
  'fk1TextFilter'      => new sfWidgetFormInput(),
  'fk2'                => new sfWidgetFormPropelChoice(array('model' => 'table2',  'add_empty' => true,)),
  'fk2TextFilter'      => new sfWidgetFormInput(),
  ));

$this->setValidators(array(
  'fk1TextFilter'      => new sfValidatorPropelChoice(array('model' => 'table1', 'column' => 'id', 'required' => false)),
  'fk1'                => new sfValidatorPropelChoice(array('model' => 'table1', 'column' => 'id', 'required' => false)),
  'fk2TextFilter'      => new sfValidatorPropelChoice(array('model' => 'table2', 'column' => 'id', 'required' => false)),
  'fk2'                => new sfValidatorPropelChoice(array('model' => 'table2', 'column' => 'id', 'required' => false)),
));

$this->validatorSchema->setPostValidator(
  new sfValidatorPropelUnique(array('model' => 'table2', 'column' => array('fk2')))
);

$this->widgetSchema->setNameFormat('model[%s]');

$this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

}

This is: created 2 textInput and 2 dropdowns as stated earlier.

If I use -could be the inputtext or the dropdowns- just the fk this will work OK. the problem is that I can’t duplicate the fk’s. I can’t do:

  $this->setWidgets(array(
  'fk1'   => new sfWidgetFormPropelChoice(array('model' => 'table1',  'add_empty' => true,)),
  'fk1'   => new sfWidgetFormInput(),
  'fk2'   => new sfWidgetFormPropelChoice(array('model' => 'table2',  'add_empty' => true,)),
  'fk2'   => new sfWidgetFormInput(),
  ));

If I run the page I get:

You must define a "filterByfk1TextFilter" method in the ModelQuery class to be able to filter with the "fk1TextFilter" field.

I found some links (1, 2) but is not working for me. I don’t have in the symfony docs concrete examples.

What I must created and how?

By now I have, in the same lib/filter/table1/ModuleFormFilter:

 public function getFields()
 {
  $fields = parent::getFields();
  $fields['fk1TextFilter'] = 'fk1TextFilter';
  $fields['fk2TextFilter'] = 'fk2TextFilter';
  return $fields;
 }

public function addModelfk1TextFilterQuery($query, $field, $value)
{
 //add your filter query!
 //for example in your case
 $rootAlias = $query->getRootAlias();
 $query =  ModelQuery::create()
  ->filterByfk1TextFilter()
  ->find();

 //remember to return the $query!
 return $query;
}

Is not working for me. Could you help me please??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T00:24:17+00:00Added an answer on June 2, 2026 at 12:24 am

    Black Magic:

    There are many different ways. None worked for me, at least those in the links I posted.

    Nevertheless, using: add[VirtualColumnName]ColumnCriteria allows you to customize filters.

    In this case, after all the code I wrote (and changing addModelfk1TextFilterQuery()) just add:

    public function addfk1TextFilterColumnCriteria($query, $field, $value)
    {
      //Here just put a query in propel, for ex:
    
      $query = $query->useTableModel()
                     ->filterByName("*$value*")
                   ->endUse()
                   ->find();
     return $query;
    }
    

    Hoping that this will help some others!

    Mini Edit: do some echoes to $field and $values for clarification

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have table structure with 3 colums (column1, column2, column3) and i want to
I have table with 3 columns A B C. I want to select *
I have table with a unique auto-incremental primary key. Over time, entries may be
i have table unser it i have one td with elemets inside the menu
I have table in data base name train delay, with columns train number(int), DelayTime(int),
I have table A in Oracle that has a primary key (id). I need
I have table called stats . In am inserting yes or no in the
I have table that I insert data with following query (from c# code): INSERT
I have table 'products' and I need to update 'price' field by 20% if
I have table where I track various statistics about site usage. Once a week,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.