Cakephp 3.6: Create new view with dropdown and check boxes












0















I am building a task manager application and among other I have these tables:



TaskTypes : [id, name, instructions]



TaskElements : [id, name, description, task_type_id, element_category_id]



ElementCategories : [id, name]



In the TaskTypes view.cpt I want to create a button which will open a new screen where the user can select an Element Category from a drop down menu and then will see a table with all the TaskElements that belong to this Element Category. Each row (Task Element) will have a checkbox, so the user can select Task Elements and then with a Submit button the selected Task Elements will be duplicated with the task_type_id filled from the TaskTypes view.cpt.



Because I am fairly new to cakephp I have these questions:



How I can write the code to update the table based on the dropdown selection?



I have created these new files:



addelementindex.ctp and AddElementController.php:



AddElementController.php:



<?php
namespace AppController;

use AppControllerAppController;

/**
* AddElement Controller
*/
class AddElementController extends AppController
{

/**
* Index method
*
* @return CakeHttpResponse|void
*/
public function index()
{
$elementCategories = TableRegistry::get('ElementCategories')->find('list', ['limit' => 200]);

$this->set(compact('elementCategories'));
}
}









share|improve this question

























  • What you're looking for is Ajax. Should be lots of examples out there of using Ajax to populate a page based on a dropdown selection. For the Ajax side of things, it doesn't care at all that your application is implemented in CakePHP, so you don't need to find a solution that's Cake-centric.

    – Greg Schmidt
    23 hours ago
















0















I am building a task manager application and among other I have these tables:



TaskTypes : [id, name, instructions]



TaskElements : [id, name, description, task_type_id, element_category_id]



ElementCategories : [id, name]



In the TaskTypes view.cpt I want to create a button which will open a new screen where the user can select an Element Category from a drop down menu and then will see a table with all the TaskElements that belong to this Element Category. Each row (Task Element) will have a checkbox, so the user can select Task Elements and then with a Submit button the selected Task Elements will be duplicated with the task_type_id filled from the TaskTypes view.cpt.



Because I am fairly new to cakephp I have these questions:



How I can write the code to update the table based on the dropdown selection?



I have created these new files:



addelementindex.ctp and AddElementController.php:



AddElementController.php:



<?php
namespace AppController;

use AppControllerAppController;

/**
* AddElement Controller
*/
class AddElementController extends AppController
{

/**
* Index method
*
* @return CakeHttpResponse|void
*/
public function index()
{
$elementCategories = TableRegistry::get('ElementCategories')->find('list', ['limit' => 200]);

$this->set(compact('elementCategories'));
}
}









share|improve this question

























  • What you're looking for is Ajax. Should be lots of examples out there of using Ajax to populate a page based on a dropdown selection. For the Ajax side of things, it doesn't care at all that your application is implemented in CakePHP, so you don't need to find a solution that's Cake-centric.

    – Greg Schmidt
    23 hours ago














0












0








0








I am building a task manager application and among other I have these tables:



TaskTypes : [id, name, instructions]



TaskElements : [id, name, description, task_type_id, element_category_id]



ElementCategories : [id, name]



In the TaskTypes view.cpt I want to create a button which will open a new screen where the user can select an Element Category from a drop down menu and then will see a table with all the TaskElements that belong to this Element Category. Each row (Task Element) will have a checkbox, so the user can select Task Elements and then with a Submit button the selected Task Elements will be duplicated with the task_type_id filled from the TaskTypes view.cpt.



Because I am fairly new to cakephp I have these questions:



How I can write the code to update the table based on the dropdown selection?



I have created these new files:



addelementindex.ctp and AddElementController.php:



AddElementController.php:



<?php
namespace AppController;

use AppControllerAppController;

/**
* AddElement Controller
*/
class AddElementController extends AppController
{

/**
* Index method
*
* @return CakeHttpResponse|void
*/
public function index()
{
$elementCategories = TableRegistry::get('ElementCategories')->find('list', ['limit' => 200]);

$this->set(compact('elementCategories'));
}
}









share|improve this question
















I am building a task manager application and among other I have these tables:



TaskTypes : [id, name, instructions]



TaskElements : [id, name, description, task_type_id, element_category_id]



ElementCategories : [id, name]



In the TaskTypes view.cpt I want to create a button which will open a new screen where the user can select an Element Category from a drop down menu and then will see a table with all the TaskElements that belong to this Element Category. Each row (Task Element) will have a checkbox, so the user can select Task Elements and then with a Submit button the selected Task Elements will be duplicated with the task_type_id filled from the TaskTypes view.cpt.



Because I am fairly new to cakephp I have these questions:



How I can write the code to update the table based on the dropdown selection?



I have created these new files:



addelementindex.ctp and AddElementController.php:



AddElementController.php:



<?php
namespace AppController;

use AppControllerAppController;

/**
* AddElement Controller
*/
class AddElementController extends AppController
{

/**
* Index method
*
* @return CakeHttpResponse|void
*/
public function index()
{
$elementCategories = TableRegistry::get('ElementCategories')->find('list', ['limit' => 200]);

$this->set(compact('elementCategories'));
}
}






php html cakephp






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited yesterday







aggtr

















asked yesterday









aggtraggtr

328




328













  • What you're looking for is Ajax. Should be lots of examples out there of using Ajax to populate a page based on a dropdown selection. For the Ajax side of things, it doesn't care at all that your application is implemented in CakePHP, so you don't need to find a solution that's Cake-centric.

    – Greg Schmidt
    23 hours ago



















  • What you're looking for is Ajax. Should be lots of examples out there of using Ajax to populate a page based on a dropdown selection. For the Ajax side of things, it doesn't care at all that your application is implemented in CakePHP, so you don't need to find a solution that's Cake-centric.

    – Greg Schmidt
    23 hours ago

















What you're looking for is Ajax. Should be lots of examples out there of using Ajax to populate a page based on a dropdown selection. For the Ajax side of things, it doesn't care at all that your application is implemented in CakePHP, so you don't need to find a solution that's Cake-centric.

– Greg Schmidt
23 hours ago





What you're looking for is Ajax. Should be lots of examples out there of using Ajax to populate a page based on a dropdown selection. For the Ajax side of things, it doesn't care at all that your application is implemented in CakePHP, so you don't need to find a solution that's Cake-centric.

– Greg Schmidt
23 hours ago












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54251215%2fcakephp-3-6-create-new-view-with-dropdown-and-check-boxes%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54251215%2fcakephp-3-6-create-new-view-with-dropdown-and-check-boxes%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Liquibase includeAll doesn't find base path

How to use setInterval in EJS file?

Petrus Granier-Deferre