This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use Stack Overflow.

Enable fillin for one single action (without validation)

Social code snippet repository

Enable fillin for one single action (without validation)

by roga » Tue Feb 13, 2007 6:12 pm

The challenge:
My application uses a dynamically generated form - therefore I have to use a custom validationXXX() method to validate form input because the field names will change on each request.

There is currently no way to enable the fillin filter for only one single action, if you use a custom validationXXX() method.

The solution:
You have two choices to enable fillin filter:
METHOD 1: add the fillin filter in filters.yml
-> drawback: it will be executed for every action -> overhead)

METHOD 2: create a .yml validation file and enable fillin
Code: Select all
./validate/xxx.yml:

fillin:
  enabled: on


This will throw an exception because symfony looks for a "fields" key.

So I tried:
Code: Select all
./validate/xxx.yml:

fillin:
  enabled: on

fields: []


No error, but also no fillin filter. It's disabled automatically because symfony doesn't find any validation fields.

So the solution is to use a hidden input field:
Code: Select all
./validate/xxx.yml:

fillin:
  enabled: on

fields:
  hiddenfield:
    required: yes

./templates/myactionSuccess.php:

...
<?php echo hidden_tag('hiddenfield', 1); ?>
...
roga
Member
 
Posts: 55
Joined: Thu Dec 28, 2006 8:45 pm

Re: Enable fillin for one single action (without validation)

by Stegnation » Fri Mar 16, 2007 1:50 am

I did it like this:
Code: Select all
methods:
  post: [anything]

names:
  anything:
    required:     false

fillin:
  enabled: on
Stegnation
Junior Member
 
Posts: 17
Joined: Thu Jul 06, 2006 12:11 pm
Location: Netherlands