Posts tagged with ‘symfony framework’

Symfony Filter: Change ForeignKey drop down to Text field

advertisement

symfonyI tried to change the foreignkey drop down to text field in the symfony filter form. But after i change the drop down field to text field, my field name changed to xxx_filter[‘foreign_id’][‘text’] instead of xxx_filter[‘foreign_id’]. And everytime i submit the form it show “SQLSTATE[HY093]: Invalid parameter number: parameter was not defined”.

After few hours of googling, i manage to find the solution for this filter form problem. To solve the problem follow the steps below:-

Continue reading Symfony Filter: Change ForeignKey drop down to Text field »

Symfony: How to escape hash # character in yaml

advertisement

Just a quick note for myself to escape # character in yaml – Symfony. When i’m trying to load batch data, some of the record seems not imported successfully especially with hash # character. By default, all the string behind the hash # character is treated as comment.

Here’s the example to escape hash # character:-

Continue reading Symfony: How to escape hash # character in yaml »

Symfony: Control Model->save() function to perform INSERT or UPDATE

advertisement

In Symfony Framework, Model->save() function is clever enough to determine to use INSERT or UPDATE for the query. But i’ve tried many ways to perform an UPDATE for my record but failed. It keep INSERT new record. Finally i found the solution to control the Model->save() function to perform INSERT or UPDATE.

Just a simple example:-
Assume there is a User table where ID is the primary key, and there is a user record with id = 5, now we perform the code below, it should be smart enough to perform UPDATE but NO!, the code below will INSERT a new record.

Continue reading Symfony: Control Model->save() function to perform INSERT or UPDATE »