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 4325446
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T09:16:04+00:00 2026-05-21T09:16:04+00:00

I use symfony 1.4.10 I have next situation: User can create Ads and he

  • 0

I use symfony 1.4.10
I have next situation:
User can create “Ads” and he can create one “company”. My part of schema:

Ads:
  actAs:
    Timestampable: ~ 
    Sluggable:
      unique: true
      fields: [title]
      canUpdate: false
  connection: doctrine
  tableName: ads
  columns:
    ad_id: { type: integer(4), primary: true, autoincrement: true, notnull: true  }
    user_id: {type: int(4) }
    country: {type: string(255), notnull: true  }
    category_id: { type: int(4), notnull: true  }
    company: {type: string(255), notnull: true  }
    address: {type: string(255), notnull: true  }
    contact_person: {type: string(255), notnull: true  }
    phone:         { type: string(50), notnull: true }
    fax:         { type: string(50) }
    email: {type: string(255), notnull: true}
    show_in_profile: { type: boolean,notnull: true , default: false }
    title: {type: string(255), notnull: true  }
    content: {type: string(), notnull: true  }
    company: {type: string(255), notnull: true  }
    AGB: { type: boolean,notnull: true , default: false }
    active:          { type: boolean,notnull: true , default: 0 }
    expires_at:   { type: timestamp, notnull: true }
  relations:
    Owner:       { onDelete: CASCADE, local: user_id, foreign: id, class: sfGuardUser }
    Bookmark:    {                    local: ad_id, foreign: user_id, class: sfGuardUser, refClass: Bookmarks }
    Categories:  { onDelete: CASCADE, local: ad_id, foreign: category_id }
    Images:      {                    local: ad_id, foreign: ad_id, type: many, class: Images }

Companies:
  actAs:
    Timestampable: ~
    Sluggable:
      unique: true
      fields: [company]
      canUpdate: false
  connection: doctrine
  tableName: companies
  columns:
    company_id: { type: integer(4), primary: true, notnull: true, autoincrement: true }
    user_id:  {type: int(4)  }
    category_id:  {type: int(4), notnull: true  }
    company: {type: string(255), notnull: true  }
    address: {type: string(255), notnull: true  }
    contact_person: {type: string(255), notnull: true  }
    phone:         { type: string(50), notnull: true }
    fax:         { type: string(50) }
    email: {type: string(255), notnull: true}
    url:  { type: string(50) }
    about: {type: string(), notnull: true}
    country: {type: string(255), notnull: true}
    active:          { type: boolean, default: 0 }
    has_company:        { type: boolean, default: 1 }
  relations:
    Owner:       { onDelete: CASCADE, local: user_id, foreign: id, class: sfGuardUser }
    Images_companies:      {                    local: company_id, foreign: company_id, type: many, class: Images_companies }
    Categories:  { onDelete: CASCADE, local: company_id, foreign: category_id }

sfGuardUserProfile:
  connection: doctrine
  tableName: sf_guard_user_profile
  columns:
    id:            { type: integer(4), primary: true, autoincrement: true }
    user_id:       { type: integer(4), notnull: true }
    salutation:    { type: string(10), notnull: true }
    first_name:    { type: string(30), notnull: true }
    last_name:     { type: string(30), notnull: true }
    country:       { type: string(255), notnull: true }
    postcode:      { type: string(10) , notnull: true }
    city:          { type: string(255), notnull: true }
    address:       { type: string()   , notnull: true }
    phone:         { type: string(50) }
    email:         { type: string(255), notnull: true }
    validate:      { type: string(17) }
    banned:        { type: boolean, default: 0 }
    payed_until:   { type: datetime, notnull: true}
  relations:
    User:
      class: sfGuardUser
      local: user_id
      foreign: id
      type: one
      foreignType: one
      foreignAlias: Profile
      onDelete: CASCADE

So I need in each Ads of user put link to company of this user.So I do not know how to do it…
Part of routing:

ads:
  url: /:sf_culture/account/ads/:action/*
  param: { module: ads }
  requirements:
    sf_culture: (?:de|en|ru)
companies:
  url: /:sf_culture/account/company/:action/*
  param: { module: companies }
  requirements:
    sf_culture: (?:de|en|ru)

I think that it is possible in each ad to form a link to a company, but I do not know how I can get the id of company what I need.probably add relations between “Ads” and “Company”?Maybe there is another way to make a link to company?
p.s Sorry for ma bad English

  • 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-05-21T09:16:04+00:00Added an answer on May 21, 2026 at 9:16 am

    that should be easy!
    go to the form, and add this to the configure() method

    public function configure() {
            parent::configure();
            unset(
                    $this['company_id'],
            );
    }
    

    And when the form is saved, handle this in the action:

    if ($this->form->isValid()) {               
        $user_id = // get user_id of authenticated user
        $user = // get user obj
        $company_id = $user->Companies->id;
        $temp_ad = $this->form->getObject();
        $ad->company_id = $company_id ;
                    $this->form->save();
    }
    

    Also, in your Ads model, the relation for Companies, foreign_id should just be id

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

Sidebar

Related Questions

I use symfony 1.4.15 with doctrine. And I have category and subcategory: Category: actAs:
I use symfony 1.4.11. And I have next: $this->widgetSchema['en']['content'] = new sfWidgetFormTextareaTinyMCE(array( 'width' =>
I use symfony 1.4.11 with sfDoctrineGuardUser 4.0.1 plugin and sfSocialPlugin So, I have next
i create my new site. Now i learn and use Symfony. I have few
How I can create for with one to many relations? For example I have
So I've decided after much debate and research to use symfony on my next
I use Symfony 2 and the FOSUserBundle. I can login, logout and view Profile.
I have a Service (DependencyInjection) that i create, and i use that on my
I use symfony 1.4.11. I have frontend and backend form. Frontend : <?php {
I use symfony 1.4.11 with Doctrine. I have private messages in my site, And

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.