Symfony help

Discussion in 'PHP' started by risoknop, Nov 14, 2008.

  1. #1
    Hello,

    So I have been playing with symfony for sime time now and I like it a lot. I have tried to create my first project in it but I have got stuck on a little problem.

    I will try to explain the issue.

    I have decided to create a simple CMS just to test the symfony and to learn how it works. I am using version 1.1 and everything I have done so far was following the official documentation point by point, yet there is a problem.

    The schema.yml for my project looks like this:

    propel:
      post:
        id:            ~
        author_id:     ~
        title:         varchar(255)
        excerpt:       longvarchar
        body:          longvarchar
        created_at:    ~
        updated_at:    timestamp
      author:
        id:            ~
        name:          varchar(255)
        email:         varchar(255)
      category:
        id:            ~
        name:          varchar(255)
      tag:
        id:            ~  
        name:          varchar(255)
      comment:
        id:            ~
        post_id:       ~
        author:        varchar(255)
        email:         varchar(255)
        body:          longvarchar
        created_at:    ~
      category_post:
        category_id:   { type: integer, primaryKey: true, foreignReference: id, foreignTable: category, onUpdate: cascade, onDelete: cascade }
        post_id:       { type: integer, primaryKey: true, foreignReference: id, foreignTable: post, onUpdate: cascade, onDelete: cascade }
      tag_post:
        tag_id:        { type: integer, primaryKey: true, foreignReference: id, foreignTable: tag, onUpdate: cascade, onDelete: cascade }
        post_id:       { type: integer, primaryKey: true, foreignReference: id, foreignTable: post, onUpdate: cascade, onDelete: cascade }
      page:
        id:            ~
        title:         varchar(255)
        body:          longvarchar
        created_at:    ~
        updated_at:    timestamp
    
    Code (markup):
    As you can see, it's a pretty basic CMS schema. Next, I have built the model by executing:

    symfony propel:build-all
    Code (markup):
    Finally, I have tried to create an admin area using the admin generator:

    symfony propel:init-admin backend post Post
    Code (markup):
    The module was created successfuly and works fine but I am completely confused as how to add some basic validation to the form for adding posts.

    What I would like to do is to have a validation for title, content ect... so it won't be able to submit the form with empty fields.

    Following the official documentation, I have tried adding to the generator.yml for the post module:

    fields:
      post{title}:
        required:
          msg:        You must provide a title
    
    Code (markup):
    Which doesn't work, I can still submit a post with empty title. Yes, this is just an excerpt of my generator.yml file and it is correctly indented.

    I have also tried modifying the schema:

    post:
      id:            ~
      author_id:     ~
      title:         { type: varchar(255), required: true }
      excerpt:       { type: longvarchar, required: true }
      body:          { type: longvarchar, required: true }
      created_at:    ~
      updated_at:    timestamp
    
    Code (markup):
    Then I rebuilt the model and cleared the cache, of course. And it still doesn't work.

    I am completely confused as to where I am making something wrong plus the admin generator validation isn't explained very well in the documentation, moreover there is much conflicting information.

    I would really appreciate some help from an experienced symfony user. I am very new to it, so please excuse these stupid questions.
     
    risoknop, Nov 14, 2008 IP
  2. risoknop

    risoknop Peon

    Messages:
    914
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Nobody? :(
     
    risoknop, Nov 14, 2008 IP