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

  • Home
  • SEARCH
  • 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 6025967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:22:36+00:00 2026-05-23T04:22:36+00:00

Sorry if my question is vague I tried to keep is as simple as

  • 0

Sorry if my question is vague I tried to keep is as simple as possible, I am using the following controller in cakephp:

var $uses = array('Client','Ticket','Userseequeue','Queue','Task','User');
var $useTable = false;

function index() {
    $clientsResult = $this->Client->find('all');
    $userSeeQueuesResult = $this->Userseequeue->find('all', array('conditions' => array('Userseequeue.user_id' => '1') ) );
    $ticketsResult = $this->Ticket->find('all');
    $queuesResult = $this->Queue->find('all');
    $tasksResult = $this->Task->find('all', array('group' => array('Task.ticket_id','Task.queue_id') ) );
    $usersResult = $this->User->find('all');
    $this->set(compact('tickets','userSeeQueues','clients','queuesResult','tasksResult','users','ticketUsers','ticketQueues'));
    if (!empty($this->data)) {
        $this->Ticket->create();
        $this->Ticketsinqueue->insertData($this->data);
        if ($this->Ticket->save($this->data) && $this->Ticketsinqueue->save($this->data)) {
            $this->Session->setFlash(__('The ticket has been saved', true));
            $this->redirect(array('action' => 'index'));
        } else {
            $this->Session->setFlash(__('The ticket could not be saved. Please, try again.', true));
        }
    }
}

And I use these tables to display a summary of information on a single view.

I need to add a form on that view screen to add an additional ticket. What am i doing wrong or missing to create this form and have it save to the table?

Here is my view where I tried to create the form, in case it might help:

<div class="Summary index">
<h2><?php __('Summary');?></h2>
<?php echo $this->Form->create('Ticket');?>
<fieldset>
    <legend><?php __('Add Ticket'); ?></legend>
<?php
    echo $this->Form->input('Ticket.name');
    echo $this->Form->input('Ticket.user_id');
    echo $this->Form->input('Ticket.queue_id');
?>
<?php echo $this->Form->end(__('Submit', true));?>
</fieldset>
...

This creates the form but it does not populate the drop down list from it’s relationships’ tables correctly as it would in the normal add view created by cakephp. It currently fills the drop down list with all the tables’ I used in this controller.

I would appreciate if anyone can assist me or help me in the right direction.

  • 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-23T04:22:37+00:00Added an answer on May 23, 2026 at 4:22 am

    I got this to work by:

    Having the controller first save the data before creating the variables for the view

    and saving the list of values, for each drop down, as a variable in the controller.

    var $uses = array('Client','Ticket','Userseequeue','Queue','Task','User');
    var $useTable = false;
    
    function index() {
        if (!empty($this->data)) {
            $this->Ticket->create();
            $this->Ticketsinqueue->insertData($this->data);
            if ($this->Ticket->save($this->data) && $this->Ticketsinqueue->save($this->data)) {
                $this->Session->setFlash(__('The ticket has been saved', true));
                $this->redirect(array('action' => 'index'));
            } else {
                $this->Session->setFlash(__('The ticket could not be saved. Please, try again.', true));
            }
        }
        $clientsResult = $this->Client->find('all');
        $userSeeQueuesResult = $this->Userseequeue->find('all', array('conditions' => array('Userseequeue.user_id' => '1') ) );
        $ticketsResult = $this->Ticket->find('all');
        $queuesResult = $this->Queue->find('all');
        $tasksResult = $this->Task->find('all', array('group' => array('Task.ticket_id','Task.queue_id') ) );
        $usersResult = $this->User->find('all');
        $ticketUsers = $this->User->find('list');
        $ticketQueues = $this->Ticket->Queue->find('list');
        $this->set(compact('tickets','userSeeQueues','clients','queuesResult','tasksResult','users','ticketUsers','ticketQueues'));
    }
    

    My view now list the values from the controller’s variables i created:

    <div class="Summary index">
    <h2><?php __('Summary');?></h2>
    <?php echo $this->Form->create('Ticket');?>
    <fieldset>
        <legend><?php __('Add Ticket'); ?></legend>
    <?php
        echo $this->Form->input('Ticket.name');
        echo $this->Form->input('Ticket.user_id', array('options' => array($ticketUsers),'empty' => 'None'));
        echo $this->Form->input('Ticket.queue_id', array('options' => array($ticketQueues)));
    ?>
    <?php echo $this->Form->end(__('Submit', true));?>
    </fieldset>
    ...
    

    With this I can have a form to add a ticket as well as display information from other models / tables all on one page.

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

Sidebar

Related Questions

Sorry for asking such a vague question, i'm new to using C# / ASP.NET.
Sorry for vague question title. I've got a table containing huge list of, say,
Sorry for the vague question.. but I'm not sure quite what the problem is.
Sorry if this question is too vague, but I'd rather not muddy it's point
Sorry about the extremely vague question title (any suggestions for improvements welcome) I have
My question title isn't clear, sorry. I tried ;) I have a binary string
Sorry to bother you with such a simple question, but I'm stuck here since
I'm sorry, I know this is a very simple question but I've search here
Sorry for vague title, I am not able to describe my question in one
I am sorry if this is a really simple question but I am really

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.