cakephp-3.0

How to save multiple records in cakephp 3

荒凉一梦 提交于 2019-12-14 03:48:34
问题 I'm very new in cakephp 3. I want to save multiple records with multiple checkbox. I've some events in events table & some passwords in passwords table. I want to set different passwords under each events. For example- For event 1 I want to set some passwords which will be stored in event_password_all table. (id, event1, password1), (id, event1, password2), (id, event1, password3), … … (id, event1, passwordN) How can I do that. Here is my controller code- public function add() {

How to create multiple checkboxes grouped by fieldsets in Cakephp 3

限于喜欢 提交于 2019-12-14 03:47:13
问题 I'm having a problem following this documentation : Cakephp3 Cookbook - Form - Creating Select Pickers I tried the 'multiple checkboxes' part : $options = [ 'Group 1' => [ 'Value 1' => 'Label 1', 'Value 2' => 'Label 2' ], 'Group 2' => [ 'Value 3' => 'Label 3' ] ]; echo $this->Form->select('field', $options, ['multiple' => 'checkbox']); but the output was an error like this : Notice (8): Array to string conversion [CORE/src/View/StringTemplate.php, line 238] it's like telling me that the value

Populate country dropdown

血红的双手。 提交于 2019-12-13 21:33:55
问题 I have a database table with columns ID , Country. Inside controller i am getting the countries from model: $countries = $countries->find('list',array('fields',array('id','country'))); $this->set('countries',$countries); In the ctp file i am trying to get the a the dropdown by setting in option value the id and in the text the country name. <?= $this->Form->input('Country of residence',array('type'=>'select','options'=>$countries)); ?> The dropdown is populated by have value the id and as

CakePHP 3 - association is not defined - even though it appears to be

倾然丶 夕夏残阳落幕 提交于 2019-12-13 19:36:24
问题 I've baked a legacy application using CakePHP 3.7 The database contains 3 tables as follows: regulations , groups , filters . The hierarchy as far as the application goes is: Regulations Groups Filters The table schemas are as follows: mysql> describe regulations; +-------+---------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------+---------------------+------+-----+---------+----------------+ | id | tinyint(3) unsigned | NO | PRI |

cakephp 3.0 isAuthorized() not being called

核能气质少年 提交于 2019-12-13 18:19:28
问题 I've followed the tutorial and all the CakePHP Authorization guide and I can't get my isAuthorized() method to be called. My understanding (correct me if I am wrong, which is incredibly likely) is by delegating authorize to the specific controllers by doing 'authorize'->['Controller'] in AppController.php , when a method in UsersController is called, in this case 'add', UsersController would run the isAuthorized() method I defined. I was testing to see if this method ran at all outputting a

Why are functions in cakephp 3.x controllers and tables public but functions in entities protected?

此生再无相见时 提交于 2019-12-13 12:19:41
问题 I am using cakephp 3.x I made this observation. Functions in controllers and tables are declared as public. Functions in entities are declared as protected. Why can't entities functions be declared as public as well? 回答1: This sounds like you have no idea when and why you use the visibility scope. See this question "What is the difference between public, private, and protected?" as well. In fact nothing prevents you from declaring a public method in an entity, try it. Nothing prevents you

ORDER BY on MySQL stored function in CakePHP 3

人盡茶涼 提交于 2019-12-13 12:09:42
问题 I'm working on cakePHP 3. I have a user defined function(UDF or Routine) in mysql database. That function takes a parameter and returns an integer value. I have to order that returned value in MySQL order clause. I know mysql query to use that function. i.e, SELECT customer_id FROM table_name ORDER BY routine_name(param1); //param1 is 'customer_id' which I have written after SELECT But I don't know that how to build this query in cakePHP 3. If anyone knows the solution, answer will be

how to create separate login for frontend and backend using cakephp 3.0 and session should be different?

早过忘川 提交于 2019-12-13 10:23:41
问题 I want to create a application where role will be different like (Admin, Partner, Student,Trainer), And I want to separate session/Auth for each role and login too. I do not want to login with Users table, even want to with student, trainer like that. Please help me. 回答1: Don't make things complex: Manage your login access from two tables: Roles: This should include all role types Users: This should include at least login information like username/email, password etc. And obviously make

so many deprecated after updating 3.4.13 to 3.6 cakephp

廉价感情. 提交于 2019-12-13 10:11:11
问题 s0o many deprecated error? How to fixed this one? Deprecated (16384): Cake\Cache\Cache::config() is deprecated. Use setConfig()/getConfig() instead. - E:\xampp\htdocs\cakephp\config\bootstrap.php, line: 136 [CORE\src\Core\functions.php, line 305] Deprecated (16384): Cake\Datasource\ConnectionManager::config() is deprecated. Use setConfig()/getConfig() instead. - E:\xampp\htdocs\cakephp\config\bootstrap.php, line: 137 [CORE\src\Core\functions.php, line 305] Deprecated (16384): Use Cake\Mailer

Ajax not calling success function

て烟熏妆下的殇ゞ 提交于 2019-12-13 09:48:23
问题 I'm using ajax to validate a from without reloadind the page. Script Ajax function updateResult(tab){ $.ajax({ url:"requeteSpecimen.php", data:{datas:tab}, dataType: 'text', async:false, success: function(data){ document.getElementById('resultat').innerHTML = '<p>'+data+'</p>'; }, error: function(data){ document.getElementById('resultat').innerHTML = '<p>ERROR</p>'; } }); } $("#filtre").submit(function(){ <?php $tab=$this->request->data; ?> updateResult(<?php json_encode($tab);?>); }); <