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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:49:06+00:00 2026-06-11T20:49:06+00:00

I have a module called main which is my default module and a module

  • 0

I have a module called main which is my default module and a module called song.

I want to put into my main module an “add form” of my song module.

I don’t know if I have to use component, how and where to process the form.

Could you please help me ?

  • 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-06-11T20:49:08+00:00Added an answer on June 11, 2026 at 8:49 pm

    Have you checked the documentation? Specially this part of the doc?

    It covers the form system by using a basic contact form:

    • You have the controller (the actions.class.php inside your main module) which create an instance of the form and handle the submission (validation, save, etc ..)
    • Then the template (contactSuccess.php), which display the form

    The main difference is that you probably have a model called Song, so you will have to use the SongForm instead of creating a new one (using new sfForm()). For this part, you can see, on the same documentation page, the part Forms Based on a Model which cover the case of an article model.

    Edit:

    A step by step:

    In your main/actions/actions.class.php:

    public function executeIndex($request)
    {
      $this->form = new SongForm();
      if ($request->isMethod('post'))
      {
        $this->form->bind($request->getParameter('song'));
        if ($this->form->isValid())
        {
          $song = $this->form->save();
    
          $this->getUser()->setFlash('notice', 'Thank you, the song has been added');
    
          $this->redirect('main/index');
        }
      }
    }
    

    In your template, main/templates/indexSuccess.php:

    <?php if ($sf_user->hasFlash('notice')): ?>
      <div class="flash_notice"><?php echo $sf_user->getFlash('notice') ?></div>
    <?php endif ?>
    
    <?php echo $form->renderFormTag('main/index') ?>
      <table>
        <?php echo $form ?>
        <tr>
          <td colspan="2">
            <input type="submit" />
          </td>
        </tr>
      </table>
    </form>
    

    And you’re done.

    I really encourage you to read the whole Jobeet tutorial. You will learn lots of things. Basically every thing I described here, is in this tutorial.

    For the sf_guard_user field, you should redefine it as hidden, and then set a default value with the current connected user.

    Create a new form: /lib/form/CustomSongForm.class.php

    <?php
    
    class CustomSongForm extends SongForm
    {
      public function configure()
      {
        parent::configure();
    
        $this->widgetSchema['sf_guard_user_ud'] = new sfWidgetFormInputHidden();
      }
    }
    

    Then you can define the default, like you said:

    }$this->form->setDefault('sf_guard_user_id', $this->getUser()->getId());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a module called nbemail.py and in this module I want to use
I have a module called MyApp, and another module called MyAppTests which has a
I have a mex module called p.mexw64 which uses another dll called p.dll The
I have a PowerShell module called Test.psm1. I want to set a value on
I have created a class called Class1, and in another module, I want to
I have a module something like this, in lib, called Fool.pm, which is based
I have a main kernel module with which other kernel modules communicate. I have
I have a module that I import to my main application called pageprocs.py with
I have a dictionary called fsdata at module level (like a global variable). The
I have a long running process that is called via a Nancy Module Get

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.