Thursday, April 30, 2015

Re: Add new fields to a database table

I'd actually like an answer to the question, as I do need it. Please no "you shouldn't do that", I need to do that

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Wednesday, April 29, 2015

Cakephp 302 display white screen index on browser

I've just install cakephp 302, but have a problem here, index only show blank page, pls help!

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Cakephp 3 LoggerPlugin

Hi 

I wanted to create a plugin to manage the logs in the database. However, the whole thing will not work.^
What I have done:

  1. Bake a plugin (bin/cake bake plugin DatabaseLogger)
  2. Create the folder Log and Log/Engine in the Folder src and the php-File DatabaseLog in Log/Engine
DatapaseLog.php:
<?php

namespace DatabaseLog\Log\Engine;

use Cake\Log\Engine\BaseLog;

class DatabaseLog extends BaseLog{

    private $Model;

    public function __construct(array $config = []){
        parent::__construct($config);
    }

    public function log($level, $message, array $context = []){
        //.. Code
    }
}

my bootstrap.php
Plugin::load('DatabaseLogger', ['autoload' => true]);

my app.php
 'Log' => [
        'debug' => [
            'className' => 'DatabaseLogger.DatabaseLog'
        ]
      ],

when I open the application, I get the following error message: Could Not load class DatabaseLog

Why is the class does not load?

Thanks, Patrick

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Re: Redirect everything except start page to https



Τη Τετάρτη, 29 Απριλίου 2015 - 1:09:45 μ.μ. UTC+3, ο χρήστης Sven Mäurer έγραψε:

In my config file I have created two VirtualHosts. Below is the config that redirects to 443 where everything is configured and working. Now I want to make the startpage reachable without ssl but not the other pages. How can I achieve that?

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://1111.1111.1111

Back in the days of CakePHP 1.3, I did something similar by adding the following code in my controllers beforeFilter() function.
I believe this will also work with CakePHP 2 as well.

        // make sure that we are using ssl protocol
        if (!isset($_SERVER['HTTPS']))
             $this->redirect('https://' . $_SERVER['SERVER_NAME'] . $this->here);

HTH
Athanassios

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

CakePHP 2.6 and PHP PHP 5.6.7-1. Cabnnot run i18n shell

Hi everyone
After I upgraded my test server from Debian Wheezy (PHP 5.4) to Jessie (PHP 5.6.7-1) I can no longer run my i18n shell.

The error I am getting is :

Error: Class FMFile does not exist
#0 /var/www/hermonax/lib/Cake/Console/Command/Task/ExtractTask.php(498): ReflectionClass->__construct('FMFile')
#1 /var/www/hermonax/lib/Cake/Console/Command/Task/ExtractTask.php(475): ExtractTask->_extractPluginValidationMessages(NULL)
#2 /var/www/hermonax/lib/Cake/Console/Command/Task/ExtractTask.php(292): ExtractTask->_extractValidationMessages()
#3 /var/www/hermonax/lib/Cake/Console/Command/Task/ExtractTask.php(237): ExtractTask->_extract()
#4 /var/www/hermonax/lib/Cake/Console/Shell.php(444): ExtractTask->execute()
#5 /var/www/hermonax/lib/Cake/Console/Shell.php(441): Shell->runCommand('execute', Array)
#6 /var/www/hermonax/lib/Cake/Console/ShellDispatcher.php(209): Shell->runCommand('extract', Array)
#7 /var/www/hermonax/lib/Cake/Console/ShellDispatcher.php(66): ShellDispatcher->dispatch()
#8 /var/www/hermonax/app/Console/cake.php(47): ShellDispatcher::run(Array)
#9 {main}



The rest of the application seems to work without problems,

Thanks in Advance
Athanassios

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Redirect everything except start page to https

In my config file I have created two VirtualHosts. Below is the config that redirects to 443 where everything is configured and working. Now I want to make the startpage reachable without ssl but not the other pages. How can I achieve that?

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://1111.1111.1111

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

What are the advantages in using composite primary key since it has been supported in cakephp v3?

Cakephp 2.x did not support composite primary keys and it worked pretty fine. Cakephp 3.x added support for composite primary keys. I am not knowledgeable enough to know what are the advantages in using composite primary key. When should we use composite primary key?

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Tuesday, April 28, 2015

How to root URL like mydomain.com/username

Hi,
I'm using cake 3.x. I like to provide a unique URL (Like mydomain.com/{{username}} ) for public profile pages of my users.
Is there any possibility in cake 3.x to do that easily ?  

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

How to use rooting liek mydomain.com/username

Hi,
I'm using cake 3.x 
I like to provide a unique url (like mydomain.com/username) of their profile page for each user of my site.
I there any way to do that with cake 3.x rooting ?

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

What are the improvements made on Cakephp ver3.x over the older versions?

I have used Cakephp ver2.x in the past and am pretty happy about it. Not sure if I should upgrade to ver3.x. May I know what are the improvements made in ver3.x compared to ver2.x? Any compelling improvements? So far, what are the grumbles, if any, with users who migrated from 2.x to 3.x?

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

patchEntify() problem using cakephp 3.0

Hi, I want to import log file and add in Controller, then my log content is:

20150424,161711,checkStart,1,Android ID: ea6485a49d63d127
20150424,161711,checkStart,1,Serial ID: 38KCIUJIWZ
20150424,161711,checkStart,1,Kernel Version: #276

Here is my code,

if(($handle = fopen( $this->request->data['upload']['tmp_name'], 'r')) !== FALSE) {
       while(($data = fgetcsv($handle, 1000, ',')) !== FALSE ) {
              $this->request->data['date']        = $data[0];
              $this->request->data['time']        = $data[1];
              $this->request->data['running']     = trim( $data[2] );
              $this->request->data['status']      = trim( $data[3] );
              $this->request->data['responses']   = trim( $data[4] );
              $testActivityLog = $this->TestActivityLog->patchEntity($testActivityLog, $this->request->data);
              if (! $this->TestActivityLog->save($testActivityLog)) {
              
              }
       }
}
fclose( $handle );

When $this->request->data through patchEntify(), my data become:

	'properties' => [  		'date' => object(Cake\I18n\Time) {    			'time' => '1970-08-22T00:00:00+0000',  			'timezone' => '+00:00',  			'fixedNowTime' => false  		  		},  		'time' => object(Cake\I18n\Time) {    			'time' => '1970-01-02T20:55:11+0000',  			'timezone' => '+00:00',  			'fixedNowTime' => false  		  		},  		'running' => 'checkStart',  		'status' => true,  		'responses' => 'Android ID: ea6485a49d63d127'  	],

I don't want my date and time is the array, I hope it is:

	'properties' => [  		'date' => '20150424',
		'time' => '161711',
		'running' => 'checkStart',  		'status' => true,  		'responses' => 'Android ID: ea6485a49d63d127'  
	], 

How can I do?

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Sunday, April 26, 2015

Error: Table categories for model Categories was not found in datasource default.

am planning to use cake php as webservice
i bulid the url like this (host/al_ecom_service/Category/getCategoryDetails/id/1/)
here i can get the output as a json.(did some chenges in while return.)
it working perfectly in localhost.
its not working after moved to the live, am getting following error
Missing Database Table
Error: Table categories for model Categories was not found in datasource default.
i assume that model $useTable is not working here.

Controller
----------------------
<?php 
class CategoryController extends AppController {
var $name = 'Categories'; 
var $uses = array('Categories', 'Products');
function getCategoryDetails() {
        $categories = $this->Categories->find('all', array(
'conditions' => array('Category.sub_category_status' => 1, 'Category.sub_category_id' => 1 ),
'fields' => array('Category.sub_category_name,Category.sub_category_status, Category.sub_category_id, Category.main_category_id, Category.sub_category_status')
));
   echo json_encode($categories);
        exit;
}
}
Model
------------------
<?php
class Categories extends AppModel {
  var $useTable = 'al_data_categories_subs';
}  

My Error log
-------------------
2015-04-27 05:35:20 Error: [MissingTableException] Table categories for model Categories was not found in datasource default.
Exception Attributes: array (
  'table' => 'categories',
  'class' => 'Categories',
  'ds' => 'default',
)
Request URL: /al_ecom_service/Category/getCategoryDetails/id/1/
Stack Trace:
#0 /home/affordablear/public_html/al_ecom_service/lib/Cake/Model/Model.php(3496): Model->setSource('categories')
#1 /home/affordablear/public_html/al_ecom_service/lib/Cake/Model/Model.php(2900): Model->getDataSource()
#2 /home/affordablear/public_html/al_ecom_service/lib/Cake/Model/Model.php(2872): Model->_readDataSource('first', Array)
#3 /home/affordablear/public_html/al_ecom_service/app/Controller/CategoryController.php(63): Model->find('first', Array)
#4 [internal function]: CategoryController->getCategoryDetails('id', '1')
#5 /home/affordablear/public_html/al_ecom_service/lib/Cake/Controller/Controller.php(490): ReflectionMethod->invokeArgs(Object(CategoryController), Array)
#6 /home/affordablear/public_html/al_ecom_service/lib/Cake/Routing/Dispatcher.php(185): Controller->invokeAction(Object(CakeRequest))
#7 /home/affordablear/public_html/al_ecom_service/lib/Cake/Routing/Dispatcher.php(160): Dispatcher->_invoke(Object(CategoryController), Object(CakeRequest), Object(CakeResponse))
#8 /home/affordablear/public_html/al_ecom_service/app/webroot/index.php(108): Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse))
#9 {main}

Thanks In advance

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Facing problem with CakePHP 3.0.1 Routing, Please Help me ASAP

Hi ,
i am a software engineer. i have working with cakephp since 2011. i was good at cakephp 2. after that i was totally detached from cakephp. recently i am back and last day i try to install and totally you improve lot of things with new version 3. i have created a sample blog project and create all the action model view. i point to article index action, its working fine. but when i click to edit or view article then problem cumming i am trying but can not figure it. Need help

while browsing : url/articles/view/1

show error:

Not Found

The requested URL /lionsbusiness/articles/view/1 was not found on this server. 

Apache/2.4.9 (Win64) PHP/5.5.12 Server at localhost Port 80


Please help me to solve this really urgent. it will be very helpful to me if any one attach a simple blog cakephp 3.0.1 project in reply thus i can understand what is my fault.


Thanks in advance

ziyed
 

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Saturday, April 25, 2015

Cake 3: Map Entity mutators/virtuals with a database type

i'd like to use the database type of an Entity's field as a HTML class to provide CSS formatting for the cell.

i know i can do this in the Controller via
$this->SomeTable->schema()->columnType('some_column');

which leads to
foreach ($this->SomeTable->schema()->columns() as $column) {
    $columnTypeMap[$column] = $this->SomeTable->schema()->columnType($column);
}
// etc.

i can then use this mapping to set the cell class with the value (see first 4 cells in screenshot).
i'd also like to do this for some mutators & virtual properties. However, since the mutators aren't columns directly from a table, there appears to be no way to do it for them. For instance:

The last 3 columns above don't provide database types.

Is there any clean/clever/elegant way to do this? i realize some virtuals probably can't realistically do this (such as concatenating several fields together), but two of those are "date-ish", and based on actual DATE-type columns.


Any ideas? Perhaps alternatives to this approach?


Thanks.


-joe t.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Cake PHP 3.0 Ajax JSON

I am trying to implement a search module by using AJAX.

There is an index.ctp file in my Items Controller and I have linked my index.ctp file of Items to my search.ctp file which is present under Items controller as below:

For the search.ctp pages the URL displayed is : http://onlineelectronic.com/Items/search

In my search.ctp file the code is as follows:

<head>



   
<title> Search Results</title>

   
<?php echo $this->Html->script('//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js', array('inline' => false));?>

   
<script type="text/javascript">

        $
(document).ready(function() {

            $
("#Submit1").click(function () {

                alert
('here');

                $
.ajax({

                    type
: 'post',

                    url
: "/Items/search",

                    data
: {

                        name
: search

                   
},

                    beforeSend
: function(){

                        $
("#resultField").html("Loading...");

                   
},

                    success
: function (result) {

                        jQuery
('#resultField').html(result.valueOf($search));

                   
},

                    error
: function (response, error) {

                        alert
("Search :Error"+error);

                   
},

                    dataType
: 'json',

                    global
: false

               
});

           
});

       
});

   
</script>

</head>

<div>

   
<?= $this->Form->create() ?>

   
<fieldset>

   
<legend><?= __('Search Item') ?></legend>

   
<?php

    echo $this
->Form->input('search',['label'=>'Search']);

   
?>

   
</fieldset>

   
<?=$this->Form->submit('Search Items',['id'=>'Submit1']); ?>

   
<?= $this->Form->end() ?>

</div>

<fieldset>

   
<div id="resultField">

   
</div>  
</fieldset>


So my ItemsController code is as follows:
 
class ItemsController extends AppController
{




   
public $helpers = ['Form', 'Html', 'Time'];


   
public function initialize()
   
{
        parent
::initialize();
        $this
->loadComponent('RequestHandler');
   
}


   
public function search(){
   
//dummy
   
}


   
/**
     *obtains search result for a given string.
     */

   
public function searchData()
   
{
       
        echo
"here";
        $search_data
=[];
        var_dump
($search_data);
       
//$search_results = [];
       
if ($this->request->is('post')) {
            $search_data
= $this->request->data;
            $search_data
=implode("|",$search_data);
            $search_results
= $this->Items->find('all', array('conditions'=>array('Items.itemName LIKE'=>"%$search_data%")));
           
if(!empty($search_results)) {
                $this
->set(compact($search_results));
                $this
->set('_serialize',array('search_results'));
                echo json_encode
($search_results);
           
}
       
}


   
}

   
public function beforeFilter(Event $event)
   
{
        parent
::beforeFilter($event);

        $this
->Auth->allow(['index', 'view','search','searchData']);

   
}
}


What i have observed is that form tries to call action method search() from Items Controller so I included a dummy method in controller with no code.
But when the submit button is clicked only the alert comes up and then the page is no more responsive.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Preferred way to retrieve data with cake 3.0

Hi

I am making the move from cake 2.x to 3.x

I am starting a new project so figured this a good time.  I have been reading the book alot and its starting to make more sense.

I have been playing with different ways of retrieving my data and am a little confused as to the best practice method for retrieving data.

Coming from cake 2.0 This method is familiar to me:

// In a controller or table method.  $query = $articles->find('all', [      'conditions' => ['Articles.created >' => new DateTime('-10 days')],      'contain' => ['Authors', 'Comments'],      'limit' => 10  ]);
However, cake 3.0 seems to use this method as well

$query = $articles->find('all')      ->where(['Articles.created >' => new DateTime('-10 days')])      ->contain(['Comments', 'Authors'])      ->limit(10);
Is one "better" than the other?

Another quick question is how do I quickly identify if the above queries did not retrieve any data?  I used to check for an empty array on the returned results.  

Many Thanks!

Aaron

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Get end time from start and duration

Hi, I need some help...
I have this form with 3 fields:

echo $this->Form->input('visit_type_id', array(
    'label' => 'Tipo Visita',
));
echo $this->Form->input('start', array(
    'id' => 'start',
'label' => 'Inizio',
'dateFormat' => 'DMY',
'timeFormat' => '24',
'interval' => 15,
'minYear' => 2015,
));
echo $this->Form->input('end', array(
   'type'=>'hidden',
));

Based on "start" time and "duration" field in "visit_type_id" table I need to get "end" time into the form when submit...

I hope I've explained myself well...
thx

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Friday, April 24, 2015

Fancybox with Cakephp

Hello,

I have been trying to work on fancybox with cakephp. All i need is to display a single image in fancybox when a user clicks a link.

Here is the code that i have been using.
$src3 = 'http://farm7.staticflickr.com/6099/6359411189_0ffbb4719f_b.jpg';    $this->Fancybox->setProperties( array(                        'class' => 'fancybox3',                       'className' => 'fancybox.image',                       'title'=>'Single Image',                       'rel' => 'gallery1'                         )              );  $this->Fancybox->setPreviewContent('Click to View Image');   $this->Fancybox->setMainContent($src3); // the content which will be shown in Fancybox  echo $this->Fancybox->output(); 
Iam using aplugin by github. https://github.com/destinydriven/CakePHP-Fancybox-Plugin

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Thursday, April 23, 2015

Re: 3.x: SessionHelper deprecated, what's the new version of this?

Thanks guys. Looks like that did the trick. Guess i expected it to be more complicated, since before it mixed Session & Flash.

On Wed, 22 Apr 2015 at 00:34 Anthony GRASSIOT <antograssiot@gmail.com> wrote:

http://book.cakephp.org/3.0/en/views/helpers/flash.html

Le 22 avr. 2015 06:17, "Andras Kende" <andras@kende.com> a écrit :
Try: 
<?= $this->Flash->render(); ?>

Andras Kende


On Apr 21, 2015, at 8:56 PM, Joe T. <thookerov@gmail.com> wrote:

Looks like SessionHelper is/will be deprecated for 3.1 and request->session() is recommended... i have this chunk of code found in my Layout/default.ctp:

    <div id="content">
        <?= $this->Session->flash(); ?>

        <?= $this->fetch('content'); ?>
    </div>

i tried $this->request->session()->flash() but get a fatal error:

Error: Call to undefined method Cake\Network\Session::flash()

Okay, so not that. i'm sure this code came from early development phases, but it never caused a problem until now (admittedly, i've been away from this project for several weeks).

What's the new equivalent to that line?

Thanks.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to a topic in the Google Groups "CakePHP" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cake-php/w9fqchhcO7U/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Re: Cakephp 3.x Validation Error issue

Hi John,

I am working on form builder here you can see the image

https://www.dropbox.com/s/tefh2auwqy97g10/form_builder.png?dl=0

It is working in cakephp 2.x fine. here are answers of your questions.

Have you studied the CakePHP book?
yes I read the cakephp 3.x cook book

What have you tried?
In cakephp 2.x I have written validations like following but I have no idea how to try multiple index validation in cakephp 3.x

Cakephp 2.x Form fields are 
$this->Form->input('FormElement.text.1.title', ['type'=>'text', 'label'=>false, 'class'=>'form-control']);

$this->Form->input('FormElement.text.2.title', ['type'=>'text', 'label'=>false, 'class'=>'form-control']);

Cakephp 2.x Model Validations are

public $validate = array(
   'text'=> array(
'mustNotEmpty'=>array(
'rule' => 'checkForText',
'message'=> '',
'last'=>true)
),
'textarea'=> array(
'mustNotEmpty'=>array(
'rule' => 'checkForTextarea',
'message'=> '',
'last'=>true)
)
);
function checkForText() {
if(!empty($this->data['FormElement']['text'])) {
foreach($this->data['FormElement']['text'] as $key=>$val) {
if(empty($val['title'])) {
$this->validationErrors['text'][$key]['title'] = "Please enter title";
}
}
}
return true;
}
function checkForTextarea() {
if(!empty($this->data['FormElement']['textarea'])) {
foreach($this->data['FormElement']['textarea'] as $key=>$val) {
if(empty($val['title'])) {
$this->validationErrors['textarea'][$key]['title'] = "Please enter title";
}
}
}
return true;
}

so the validation work like a charm on multi index input fields 'FormElement.text.1.title' etc. The form fields are dynamically added.
I am not getting any clue to convert this code in cakephp 3.x

What does not work?
In cakephp 3.x I have tried so far.

Cakephp 3.x Form fields are 
$this->Form->input('FormElements.text.1.title', ['type'=>'text', 'label'=>false, 'class'=>'form-control']);

$this->Form->input('FormElements.text.2.title', ['type'=>'text', 'label'=>false, 'class'=>'form-control']);

Cakephp 3.x Model Validations are

public function validationForFormElements($validator) {
$validator
->add('text', [
'mustNotEmpty'=>[
'rule'=>'checkForText',
'provider'=>'table',
'message'=>''
]
])
->add('textarea', [
'mustNotEmpty'=>[
'rule'=>'checkForTextarea',
'provider'=>'table',
'message'=>''
]
]);
return $validator;
}
function checkForText($value, $context) {
if(!empty($context['data']['text'])) {
foreach($context['data']['text'] as $key=>$val) {
if(empty($val['title'])) {
I have no idea how add validation error on particular index
}
}
}
return true;
}
function checkForTextarea($value, $context) {
if(!empty($context['data']['textarea'])) {
foreach($context['data']['textarea'] as $key=>$val) {
if(empty($val['title'])) {
I have no idea how add validation error on particular index
}
}
}
return true;
}

Do you get any error messages?
I did not get any error messages

Please let me know if anything is not clear.

On Thursday, April 23, 2015 at 10:30:23 PM UTC+5:30, John Andersen wrote:
Please provide more information and also real life examples of your form code, so that we may better be able to help.

Have you studied the CakePHP book?
What have you tried?
What does not work?
Do you get any error messages?

Please show the validation code you have tried, the code for the form and whatever else that may help us understand your problem.

Kind regards
John Aage Andersen

On Wednesday, 22 April 2015 01:30:20 UTC+3, Cake Developer wrote:
Hi,

I am facing issue on form input validations errors. my input fields are following

$this->Form->input('FormElements.text.1.title', ['type'=>'text', 'label'=>false, 'class'=>'form-control']);

$this->Form->input('FormElements.text.2.title', ['type'=>'text', 'label'=>false, 'class'=>'form-control']);

$this->Form->input('FormElements.textarea.1.description', ['type'=>'textarea', 'label'=>false, 'class'=>'form-control']);

$this->Form->input('FormElements.textarea.2.description', ['type'=>'textarea', 'label'=>false, 'class'=>'form-control']);

Please help me anyone to apply validation rules and display errors.

Thanks in advance.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.