Admin Gen, Validation


Table of Contents

Form Validation 
Formats 
Backend and validation 
sfFileValidator optional 
sfFileValidator optional 
sfFileValidator optional 
sfFileValidator optional 
sfFileValidator optional 
Admin inline file validation 
Admin inline file validation 
partial field validation in admin gen 
partial field validation in admin gen 
validation example 
Why handleErrorEdit designed this way 

Form Validation 

Formats 

There are two valid formats, both works fine:

new 

fillin: enabled: on

fields: required: msg: Please summarize the request under 80 characters here

req{category_id}:
  required:
    msg: required
req{type_id}:
  required:
    msg: required
req{notify_type_id}:
   required:
    msg: required

old 

methods: post:

names: required:true required_msg: Please summarize the request under 80 characters here

req{category_id}:
  required:true
req{type_id}:
  required:true
req{notify_type_id}:
  required:true

I.e., first register the valid fields in methods/post, then specify the validation rule.

documented on: 2007.02.07

Backend and validation 

http://www.symfony-project.org/forum/index.php/mv/tree/3235/

I tried to add validation to the form, with a file named edit.yml, which looks like:

methods:
  get:
    - "book{title}"
    - "book{author}"
  post:
    - "book{title}"
    - "book{author}"
names:
  book{title}:
    required:     Yes
    required_msg: You must provide a title
book{author}:
  required:   No
fillin:
  activate: on

But now, as soon as I click on the "Create" button or on the "Edit" button in the list page, the edit form is displayed with the error message "You must provide a title". It looks like it tries to validate the form as soon as it displays it…

[EDIT] Ok, problem solved. Just remove the get section of the methods section in the edit.yml, and it just works great!

grigann