Tuesday, November 30, 2010

Re: Missing Method??

Hi,

Whenever you access URL like /books then it automatically goes to /books/index internally. It means if you want to provide parameter in URL for 'index' action of controller then your URL should be like /books/index/1 instead of /books/1. Otherwise you need to use route to point URLs like /books/1 to /books/index/1 internally, more help is at http://book.cakephp.org/view/945/Routes-Configuration

Amit Badkas

PHP Applications for E-Biz: http://www.sanisoft.com



On Wed, Dec 1, 2010 at 8:20 AM, Hans Wiriya Tsai <hansw.id@gmail.com> wrote:
I m trying to make a controller and a view without model. Here are the code:
Controller:
<?php
class BooksController extends AppController {
       var $name = 'Books';
       var $uses = array();

       function index($id = 0) {
               $books = array (
                               '0' => array(
                                               'book_title' => 'OOP with PHP5',
                                               'author' => 'Hasin Hayder',
                                               'isbn' => '1847192564',
                                               'release_date' => 'December 2007'
                                       ),
                               '1' => array(
                                               'book_title' => 'Building website with Joomla',
                                               'author' => 'Hagen Grraf',
                                               'isbn' => '1847192577',
                                               'release_date' => 'March 2006'
                                       )
               );
               $id = intval($id);
               if($id < 0 || $id >= count($books)) {
                       $id = 0;
               }
               $this->set($books[$id]);
               $this->set('page_heading', 'Book Store');
               $this->pageTitle = 'Welcome to the Packt Book Store!';
       }
}

View:

<h2><?php echo $page_heading; ?></h2>
<dl>
       <lh><?php echo $book_title; ?></lh>
       <dt>Author:</dt><dd><?php echo $author; ?></dd>
       <dt>ISBN:</dt><dd><?php echo $isbn; ?></dd>
       <dt>Release Date:</dt><dd><?php echo $releaseDate; ?></dd>
</dl>

Those are example from CakePHP Application Development, but
unfortunately the book was using Cake 1.2.x while I have 1.3.6
version. If I try to open it via
http://http://localhost/applogic/books/ looks OK, but if I try
http://http://localhost/applogic/books/1 an error occur like:

Missing Method in BooksController
Error: The action 1 is not defined in controller BooksController

Error: Create BooksController::1() in file:
app/controllers/books_controller.php.

<?php
class BooksController extends AppController {

       var $name = 'Books';


       function 1() {

       }

}
?>

Something not compatible between those 2 version?

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
 
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

Re: dynamically changing the type in form helper

Hi,

Are you sure that $type1 is a string?

Amit Badkas

PHP Applications for E-Biz: http://www.sanisoft.com



On Wed, Dec 1, 2010 at 7:39 AM, mochaman <mochamanbj@gmail.com> wrote:
Hi,

I want to override the input 'type' in my form using the form helper
but it is not picking up my values.  Here is a snippet:

echo $form->input($name,array('type'=>$type1,'label'=>$label));

I set $name, $type1, and $label as a strings read in from my config
xml file, however, I get the following error upon rendering the page:

Fatal error:  Method name must be a string in form.php on line 878

It appears to be an issue with $type1 since if I replace it with
'text' (ie, hardcoded), then it works but everything is a text box
rather than date or checkbox.  I have also tried putting quotes in the
data but no luck...everything just defaults to textarea.

I am a newbie to php and cake so I know it is probably something
simple...

Any assistance is appreciated.
Thanks.

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
 
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

Re: dynamically changing the type in form helper

What is the value of $type1 when you get the error?
Which version of CakePHP are you using?
What are the values of the other variables when you get the error?
Enjoy,
John

On 1 Dec., 03:09, mochaman <mochama...@gmail.com> wrote:
> Hi,
>
> I want to override the input 'type' in my form using the form helper
> but it is not picking up my values.  Here is a snippet:
>
> echo $form->input($name,array('type'=>$type1,'label'=>$label));
>
> I set $name, $type1, and $label as a strings read in from my config
> xml file, however, I get the following error upon rendering the page:
>
> Fatal error:  Method name must be a string in form.php on line 878
>
> It appears to be an issue with $type1 since if I replace it with
> 'text' (ie, hardcoded), then it works but everything is a text box
> rather than date or checkbox.  I have also tried putting quotes in the
> data but no luck...everything just defaults to textarea.
>
> I am a newbie to php and cake so I know it is probably something
> simple...
>
> Any assistance is appreciated.
> Thanks.

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

Re: Form validation and routes - errors lead to controller/action instead of route!

Hey,


ok I found the solution, and it's really simple. Just use the 'url'
option for the form, and the routes will be no problem anymore.

Here is a brief example how to do it:

In Routes-PHP, there is an entry:
Router::connect('/register', array('controller' => 'users', 'action'
=> 'register'));

And the form in the view of the register action (views/users/
register.ctp) create the form like this:

<?php echo $form->create('User', array('url' => '/register')); ?>

That points the form to the correct route, which will lead to the
correct action. On errors like empty input fields the route will be
the same again and everthing works fine.

Regards,

DD

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

Form validation and routes - errors lead to controller/action instead of route!

Hey,


the problem I have came up very often the last weeks but I couldn't
find a solution yet. Maybe one of you has a clue how to do this.

The facts:

in my users_controller i have an action called "register", which is
mapped to the route http:://www.domain.com/register

This is working, and very easy to set up. But when I now make any
mistake in the form given in the register action, the url in the
browser switches back to users/register, which is the correct action,
but not the correct route!

I could do a redirect when an error occurs, but the form validation
errors (by model validation OR invalidate()) are gone when a redirect
is done.

There has to be a solution for this, I just do not want to store all
errors in the Session and add the errors manually into the form and
delete them afterwards from the Session.

Does anyone have any idea how to solve this little problem?

Regards,

DD

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

Missing Method??

I m trying to make a controller and a view without model. Here are the code:
Controller:
<?php
class BooksController extends AppController {
var $name = 'Books';
var $uses = array();

function index($id = 0) {
$books = array (
'0' => array(
'book_title' => 'OOP with PHP5',
'author' => 'Hasin Hayder',
'isbn' => '1847192564',
'release_date' => 'December 2007'
),
'1' => array(
'book_title' => 'Building website with Joomla',
'author' => 'Hagen Grraf',
'isbn' => '1847192577',
'release_date' => 'March 2006'
)
);
$id = intval($id);
if($id < 0 || $id >= count($books)) {
$id = 0;
}
$this->set($books[$id]);
$this->set('page_heading', 'Book Store');
$this->pageTitle = 'Welcome to the Packt Book Store!';
}
}

View:

<h2><?php echo $page_heading; ?></h2>
<dl>
<lh><?php echo $book_title; ?></lh>
<dt>Author:</dt><dd><?php echo $author; ?></dd>
<dt>ISBN:</dt><dd><?php echo $isbn; ?></dd>
<dt>Release Date:</dt><dd><?php echo $releaseDate; ?></dd>
</dl>

Those are example from CakePHP Application Development, but
unfortunately the book was using Cake 1.2.x while I have 1.3.6
version. If I try to open it via
http://http://localhost/applogic/books/ looks OK, but if I try
http://http://localhost/applogic/books/1 an error occur like:

Missing Method in BooksController
Error: The action 1 is not defined in controller BooksController

Error: Create BooksController::1() in file:
app/controllers/books_controller.php.

<?php
class BooksController extends AppController {

var $name = 'Books';


function 1() {

}

}
?>

Something not compatible between those 2 version?

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

Re: Error : VALID_NOT_EMPTY

nope, maybe i should. thx for the helpful links guys.

On Tue, Nov 30, 2010 at 4:24 PM, Amit Badkas <amit.sanisoft@gmail.com> wrote:
> Hi,
> Aren't you following http://book.cakephp.org/view/1528/Blog for creating
> sample blog application?
> Amit Badkas
> PHP Applications for E-Biz: http://www.sanisoft.com
>
>
> On Tue, Nov 30, 2010 at 9:03 AM, Hans Wiriya Tsai <hansw.id@gmail.com>
> wrote:
>>
>> great, thx for the prompt help! I would of course read the entire docs
>> (later), but your quick help is very helpful for a beginner like me.
>>
>> On Tue, Nov 30, 2010 at 9:23 AM, cricket <zijn.digital@gmail.com> wrote:
>> > On Mon, Nov 29, 2010 at 5:43 AM, Hans Wiriya Tsai <hansw.id@gmail.com>
>> > wrote:
>> >> I hv CakePHP 1.3.6 installed on Ubuntu and learning to create simple
>> >> blog. When I add validation to my model, I got this error:
>> >>
>> >> Notice (8): Use of undefined constant VALID_NOT_EMPTY - assumed
>> >> 'VALID_NOT_EMPTY' [CORE/cake/libs/class_registry.php, line 141]
>> >>
>> >>
>> >> Here's my model:
>> >> <?php
>> >> class Blog extends AppModel {
>> >>        var $name = 'Blog';
>> >>        var $validate = array(
>> >>                        'title' => array(
>> >>                                        'rule' => VALID_NOT_EMPTY,
>> >>                                        'message' => 'Title of a blog
>> >> cannot be empty'
>> >>                        )
>> >>        );
>> >> }
>> >> ?>
>> >>
>> >> Any idea what this error is all about? Thx for any help.
>> >
>> > Yes, it's an undefined constant. VALID_NOT_EMPTY was deprecated awhile
>> > back. Use 'rule' => 'notEmpty' instead.
>> >
>> > http://book.cakephp.org/view/1143/Data-Validation
>> >
>> > Check out the new CakePHP Questions site http://cakeqs.org and help
>> > others with their CakePHP related questions.
>> >
>> > You received this message because you are subscribed to the Google
>> > Groups "CakePHP" group.
>> > To post to this group, send email to cake-php@googlegroups.com
>> > To unsubscribe from this group, send email to
>> > cake-php+unsubscribe@googlegroups.com For more options, visit this group
>> > at http://groups.google.com/group/cake-php?hl=en
>> >
>>
>> Check out the new CakePHP Questions site http://cakeqs.org and help others
>> with their CakePHP related questions.
>>
>> You received this message because you are subscribed to the Google Groups
>> "CakePHP" group.
>> To post to this group, send email to cake-php@googlegroups.com
>> To unsubscribe from this group, send email to
>> cake-php+unsubscribe@googlegroups.com For more options, visit this group
>> at http://groups.google.com/group/cake-php?hl=en
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others
> with their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscribe@googlegroups.com For more options, visit this group at
> http://groups.google.com/group/cake-php?hl=en
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

dynamically changing the type in form helper

Hi,

I want to override the input 'type' in my form using the form helper
but it is not picking up my values. Here is a snippet:

echo $form->input($name,array('type'=>$type1,'label'=>$label));

I set $name, $type1, and $label as a strings read in from my config
xml file, however, I get the following error upon rendering the page:

Fatal error: Method name must be a string in form.php on line 878

It appears to be an issue with $type1 since if I replace it with
'text' (ie, hardcoded), then it works but everything is a text box
rather than date or checkbox. I have also tried putting quotes in the
data but no luck...everything just defaults to textarea.

I am a newbie to php and cake so I know it is probably something
simple...

Any assistance is appreciated.
Thanks.

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

Re: Problem with Math Captcha component @ 1.3.6

I focused on this function:

function validate($data) {
if ($data == $this->Session->read('MathCaptcha.answer')){
return true;
}
}

$data exists
$this->Session->read('MathCaptcha.answer') exists


Why this function does not return 'true' when called from controller
with the following code

if ($this->MathCaptcha->validate($this->data['Contact']
['security_code'])) {
------
}

$this->data['Contact']['security_code'] exists

Thanks :)

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

Re: Multiple excel sheet download

Thanks buddy! Will do.

On Nov 26, 7:45 pm, cricket <zijn.digi...@gmail.com> wrote:
> On Thu, Nov 25, 2010 at 11:08 AM, the plumpNation <plumpnat...@gmail.com> wrote:
> > Hi guys,
>
> > I have a sales report in excel which is generated using cakephp and
> >PHPExcel. I am very happy with both of these frameworks/libraries. I
> > am really starting to feel very comfortable using them both and am
> > finally getting to the stage of being able to 'rapidly develop', the
> > whole point of cake.
>
> > Currently, the sales are generated from customers who share
> > distributors. So the logic goes
>
> > foreach(distributor){
> >   // create excel of sales using this distributor;
> >   // send email with sales to this distributor;
> > }
>
> > Then I added functionality to allow the sales manager to download the
> > sheet just to check it, before the cron ran and sent it to the
> > distributors.
>
> > foreach(distributor){
> >   // create excel of sales using this distributor;
> >  if(!browserOutput){
> >   // send email with sales to this distributor;
> >  }else{
> >  // output the excel sheet to the browser;
> >  }
> > }
>
> > Now it all works fine except that I only receive the first sheet,
> > probably because you can't do a looping download. I was just wondering
> > if anyone had an elegant solution to this that didn't involve me
> > writing the sheets to different tabs in the same excel sheet, but
> > allows the manager to receive all the sheets from the browser one at a
> > time. Maybe opening the output in different tabs or windows might
> > work, but not sure how to do this. At the moment I set headers to the
> > correct mime type like so
>
> > if($browserOutput){
>
> >                                $message .= 'for output to browser<br />';
> >                                header( 'Content-Type: application/vnd.ms-excel' );
> >                                header( 'Content-Disposition: attachment;filename="' . $filename .
> > '"');
> >                                header( 'Cache-Control: max-age=0' );
>
> >                        }
>
> > and then usePHPExcellike so
>
> > $thisSheet->save('php://output');
>
> > Whatcha fink? Is this possible or should I write all the sheets into
> > one file to download?
>
> Yes, write them all to a single file. I think that makes more sense if
> the data is all related. I suppose you could write several sheets as
> separate files, zip them up, and then output that. But that seems a
> bit strange as the sheets are already part of the same file. UsePHPExcel::createSheet().

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

Re: $_SESSION contains my data but $Session helper is empty.

Actually, after about a day of mucking around in the core, I solved
the problem. It is just a little "gotcha" with the way Cake loads
start_session(), or so it seems.

I've reproduced the bug with a clean copy of Cake 1.3.6. The reason
why the Session helper fails is only if you have browser output (like
debug output) in the beforeFilter() function of AppController or
anywhere sooner in the dispatching process.

To test, just type some pr() statement in
AppController::beforeFilter(), and then try to reproduce my original
problem above, and you'll see that the Session helper fails. BUT, if
you put something like $this->Session->check('blah') (even if 'blah'
is a nonexistent session key) BEFORE your pr() statement in
beforeFilter(), then the Session helper succeeds.

I believe the reason is because session_start() is not called early
enough in the application, but seems to be called on the first
instance of using the Session component (or helper), and if headers
have already been sent to the browser, session_start() fails. (Though
it is failing silently with my PHP error reporting set to ALL.)

Yuck! I'm glad I solved it though. I've reported issue in Lighthouse.

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

Problem with Math Captcha component @ 1.3.6

Hello, i trying to use this small piece of code

http://jamienay.com/2009/06/math-captcha-component/

here its my code:
###############################################################

MODEL:

class Contact extends AppModel {
var $name = 'Contact';
var $useTable = false;

var $_schema = array(
'name' =>array('type' => 'string', 'length' => 100),
'email' =>array('type' => 'string', 'length' => 255),
'subject' =>array('type' => 'string', 'length' => 255),
'message' =>array('type' => 'text')
);

var $validate = array(
'name' => array('minLength' => array('rule' =>
array('minLength', 3))),
'email' => array('email' => array('rule' => 'email')),
'subject' => array('notempty' => array('rule'=>'notempty')),
'message' => array('minLength' => array('rule' =>
array('minLength', 60)))
);

}
###########################################################

Controller:
....
var $components = array('RequestHandler', 'Email', 'Session',
'MathCaptcha');

function index() {
$this->set('controller_name', __('Contact',true));
$this->set('action_name', __('Index',true));
if ($this->RequestHandler->isPost()) {
$this->Contact->set($this->data);
if ($this->MathCaptcha->validates($this->data['Contact']
['security_code'])) {
if ($this->Contact->validates()) {
$this->Email->to =
Configure::read('Setting.Site.email') ;
$this->Email->subject = $this->data['Contact']
['subject'];
$this->Email->from = $this->data['Contact']['email'];
$this->Email->send($this->data['Contact']['message']);
}

}else {
$this->Session->setFlash(__('Please enter the correct
answer to the math question.', true));
}
}
$this->set('mathCaptcha', $this->MathCaptcha-
>generateEquation());
}

######################################################

view

<?php
echo $this->Form->input('name',array('label'=>__('Your
Name',true),'error'=>array('minLength'=>__('You must enter your full
name!',true))));
echo $this->Form-
>input('email',array('error'=>array('email'=>__('Please enter your
valid email!',true))));
echo $this->Form->input('subject',array('options'=>array(null
=>__('-- Choose One --',true),

__('Jobs',true)=>__('Jobs',true),

__('Orders',true)=>__('Orders',true),

__('Products',true)=>__('Products',true),

__('Brands',true)=>__('Brands',true),

__('Services',true)=>__('Services',true),

__('Partners',true)=>__('Partner',true),

__('Promotion',true)=>__('Promotion',true),

__('Other',true)=>__('Other',true)),
'label'=>__('Type of
message',true),

'error'=>array('notempty'=>__('Please choose one',true))));
echo $this->Form-
>input('message',array('type'=>'textarea','label'=>__('Message',true),'error'=>array('minLength'=>__('Your
message is to short!',true))));
echo $form->input('security_code', array('label' => __('Please
Enter the Sum of ',true) . $mathCaptcha));
?>


I detected a problem in the components, function registerAnswer not
work as intended, that does not set the session.

Help me to solve a problem:)

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

Re: CakePlate - Boilerplate CakePHP distro

Great work.
I also recommend adding something like packages.
Multilingual package
Reports package that will include excel and pdf libs for data export
etc.

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
 
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

Migrating from CakePHP 1.1 - Yikes?!

Hi,

I have a web-application written in CakePHP 1.1 which is non-trivial
and where I was not the original developer. I am just getting back
into this project now and picking it up off the ground.

I am wondering how painful it will be for me to migrate to the latest
version of CakePHP (1.3) ? I realize its a factor of the code
(details), my skills and the needs/longevity of the application - but
whats your gut feeling for a 30000+ LOC typical business app for an
senior engineer (intermediate php developer)?

Maybe I should just limp it along under 1.1?

Thanks.

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

Retrieving Posts with comments

Hello

i have a simple app that's very similar to the cookbook "Blog"
tutorial

i want to retrieve all Posts having at least one comment.

right now i'm doing this way:

$posts = $this->Post->find("all", array("contain" =>
array("Comment"));
foreach ($posts as $index => $post) {
if (empty($post["Comment"])) unset $posts[$index];
}

is there any way to achieve this by using a single ->find() call?

notes: i'm using Containable.

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

Re: Error : VALID_NOT_EMPTY

 var $validate = array(
                         'name' => array(
                                        'notempty' => array(
                                                           'rule' => 'notEmpty',
                                                           'required' => true,
                                                           'allowEmpty' => false,
                                                           'message' => 'Please enter a value for the Name field',
                                                           'last' => true
                                                            ),
                                        'unique' => array(
                                                         'rule' => array(
                                                                        'checkUnique',
                                                                        'name'),
                                                            'message' => 'Division name exists'
                                   )
                                ));

user this u will get.

all the best..

On Tue, Nov 30, 2010 at 2:54 PM, Amit Badkas <amit.sanisoft@gmail.com> wrote:
Hi,

Aren't you following http://book.cakephp.org/view/1528/Blog for creating sample blog application?

Amit Badkas

PHP Applications for E-Biz: http://www.sanisoft.com



On Tue, Nov 30, 2010 at 9:03 AM, Hans Wiriya Tsai <hansw.id@gmail.com> wrote:
great, thx for the prompt help! I would of course read the entire docs
(later), but your quick help is very helpful for a beginner like me.

On Tue, Nov 30, 2010 at 9:23 AM, cricket <zijn.digital@gmail.com> wrote:
> On Mon, Nov 29, 2010 at 5:43 AM, Hans Wiriya Tsai <hansw.id@gmail.com> wrote:
>> I hv CakePHP 1.3.6 installed on Ubuntu and learning to create simple
>> blog. When I add validation to my model, I got this error:
>>
>> Notice (8): Use of undefined constant VALID_NOT_EMPTY - assumed
>> 'VALID_NOT_EMPTY' [CORE/cake/libs/class_registry.php, line 141]
>>
>>
>> Here's my model:
>> <?php
>> class Blog extends AppModel {
>>        var $name = 'Blog';
>>        var $validate = array(
>>                        'title' => array(
>>                                        'rule' => VALID_NOT_EMPTY,
>>                                        'message' => 'Title of a blog cannot be empty'
>>                        )
>>        );
>> }
>> ?>
>>
>> Any idea what this error is all about? Thx for any help.
>
> Yes, it's an undefined constant. VALID_NOT_EMPTY was deprecated awhile
> back. Use 'rule' => 'notEmpty' instead.
>
> http://book.cakephp.org/view/1143/Data-Validation
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
 
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en



--
Master Ram.
Founder n Director of rgPlanets Pvt. Ltd.

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
 
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

Re: Error : VALID_NOT_EMPTY

Hi,

Aren't you following http://book.cakephp.org/view/1528/Blog for creating sample blog application?

Amit Badkas

PHP Applications for E-Biz: http://www.sanisoft.com



On Tue, Nov 30, 2010 at 9:03 AM, Hans Wiriya Tsai <hansw.id@gmail.com> wrote:
great, thx for the prompt help! I would of course read the entire docs
(later), but your quick help is very helpful for a beginner like me.

On Tue, Nov 30, 2010 at 9:23 AM, cricket <zijn.digital@gmail.com> wrote:
> On Mon, Nov 29, 2010 at 5:43 AM, Hans Wiriya Tsai <hansw.id@gmail.com> wrote:
>> I hv CakePHP 1.3.6 installed on Ubuntu and learning to create simple
>> blog. When I add validation to my model, I got this error:
>>
>> Notice (8): Use of undefined constant VALID_NOT_EMPTY - assumed
>> 'VALID_NOT_EMPTY' [CORE/cake/libs/class_registry.php, line 141]
>>
>>
>> Here's my model:
>> <?php
>> class Blog extends AppModel {
>>        var $name = 'Blog';
>>        var $validate = array(
>>                        'title' => array(
>>                                        'rule' => VALID_NOT_EMPTY,
>>                                        'message' => 'Title of a blog cannot be empty'
>>                        )
>>        );
>> }
>> ?>
>>
>> Any idea what this error is all about? Thx for any help.
>
> Yes, it's an undefined constant. VALID_NOT_EMPTY was deprecated awhile
> back. Use 'rule' => 'notEmpty' instead.
>
> http://book.cakephp.org/view/1143/Data-Validation
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
 
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

Re: download file

If you mean you want to your users to be prompted with a download window use readfile, otherwise I don't think I understand the question.

Here's something I did for pdf files.

http://pastie.org/private/igu2zad2lasz4vjowvdya



On 29 November 2010 06:42, Miqdad Ali <mr.miqdad.ali@gmail.com> wrote:
friends,
I want code for downloading image files in cakephp
--------------------------------------------------------------------
Miqdad Ali
http://www.miqdadali.co.cc


Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
 
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en



--
Kind Regards
 Stephen
 www.ninjacodermonkey.co.uk


Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
 
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

Re: Error : VALID_NOT_EMPTY

look at http://book.cakephp.org/view/1173/notEmpty for new validation
rules or http://book.cakephp.org/view/1151/Multiple-Rules-per-Field is
an other good point to start with validation.

On 29 Nov., 11:43, Hans Wiriya Tsai <hansw...@gmail.com> wrote:
> I hv CakePHP 1.3.6 installed on Ubuntu and learning to create simple
> blog. When I add validation to my model, I got this error:
>
> Notice (8): Use of undefined constant VALID_NOT_EMPTY - assumed
> 'VALID_NOT_EMPTY' [CORE/cake/libs/class_registry.php, line 141]
>
> Here's my model:
> <?php
> class Blog extends AppModel {
>         var $name = 'Blog';
>         var $validate = array(
>                         'title' => array(
>                                         'rule' => VALID_NOT_EMPTY,
>                                         'message' => 'Title of a blog cannot be empty'
>                         )
>         );}
>
> ?>
>
> Any idea what this error is all about? Thx for any help.

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

Re: CakePlate - Boilerplate CakePHP distro

Hi Ryan,

Great work. Nice idea , keep up the good work.


Best wishes and Regards,

Amit

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
 
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

Re: Routing with parameters

Hi,

Your route should be something like

Router:: connect ('/sitelocks', array ('controller' => 'portfolio', 'action' => 'index', 'forsale' => 1));

Amit Badkas

PHP Applications for E-Biz: http://www.sanisoft.com



On Mon, Nov 29, 2010 at 10:45 PM, xamako <xamako@gmail.com> wrote:
Hi!

I'm trying to rounting to a method of a controller with a
specific parameter.

What I'm trying to do is simulate a call like:

www.web.com/portfolio/index/forsale:1

This is what I have so far, but I do not know how to add the parameter
the call

Router:: connect ('/ sitelocks', array ('controller' => 'portfolio',
'Action' => 'index'));

Thanks!

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
 
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

Re: CakePlate - Boilerplate CakePHP distro

I'd like to have a look at this but I'm still on 1.2, may need to adapt to 1.3 and check this out.

Anyway, good work, I like the idea.


On 30 November 2010 08:19, Jeremy Burns | Class Outfit <jeremyburns@classoutfit.com> wrote:
Without downloading it, how do we find out what's included? How would anyone know if you've coded it well (to standards etc)? How easy is it to strip down pieces not needed on a specific project? What's the [Cake] upgrade path like?

Jeremy Burns
Class Outfit

jeremyburns@classoutfit.com
http://www.classoutfit.com

On 30 Nov 2010, at 04:16, ryan.pendergast@gmail.com wrote:

> You know how as a developer each time you create a new web app you
> spend the first few hours downloading, installing, and configuring the
> important add-ons that you need for nearly any production-level
> project? When all you really want to do is get started on your new
> kick-ass idea?
>
> That's why a friend and I decided to do something about it. We're
> launching CakePlate, a open source distribution of CakePHP that's
> ready to rock, right out of the box.
>
> learn more and read the full announcement at http://cakeplate.posterous.com/
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en



--
Kind Regards
 Stephen @ NinjaCoderMonkey

 www.ninjacodermonkey.co.uk


Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
 
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

Re: Associations in app_controller.php

Hi,

Are you sure that Link model has belongsTo relationship with Menu model?

Amit Badkas

PHP Applications for E-Biz: http://www.sanisoft.com



On Mon, Nov 29, 2010 at 9:33 PM, pablosky <pablo005_1@hotmail.com> wrote:
Hello.

I'm trying to extract data from a table from the app_controller.php.
But the table is related to another table using "belongTo."

This code works:

if (!Cache::read('links')) {
 $this->loadModel('Link');
 $result = $this->Link->find('all', array('fields' =>
array('Link.id', 'Link.name', 'Link.url')));
 Cache::write('links', $result);
}

But this code does not work:

if (!Cache::read('links')) {
 $this->loadModel('Link');
 $result = $this->Link->find('all', array('fields' =>
array('Link.id', 'Link.name', 'Link.url', 'Menu.alias')));
 Cache::write('links', $result);
}

Do not work in app_controller.php relationship?

Thank you!!

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
 
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

calling a view in pop up

hi .,.,.

Can someone please help me with this requirement?

i want to call a view in a pop up window.
pop up window must be popped up when user clicks on submit button.
i was searching in the web for the same for past 2 days and got nothing.
Hope i get answer here.

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
 
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

Re: CakePlate - Boilerplate CakePHP distro

Without downloading it, how do we find out what's included? How would anyone know if you've coded it well (to standards etc)? How easy is it to strip down pieces not needed on a specific project? What's the [Cake] upgrade path like?

Jeremy Burns
Class Outfit

jeremyburns@classoutfit.com
http://www.classoutfit.com

On 30 Nov 2010, at 04:16, ryan.pendergast@gmail.com wrote:

> You know how as a developer each time you create a new web app you
> spend the first few hours downloading, installing, and configuring the
> important add-ons that you need for nearly any production-level
> project? When all you really want to do is get started on your new
> kick-ass idea?
>
> That's why a friend and I decided to do something about it. We're
> launching CakePlate, a open source distribution of CakePHP that's
> ready to rock, right out of the box.
>
> learn more and read the full announcement at http://cakeplate.posterous.com/
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

Re: Console bake - modify templates

Dear Sophy

When I use that, it is a kind of submit or what?

$.ajax({
                                    type: "POST",
                                    url: "replace_expenses",
                                    data: dataString,
                                    success: function(results) {
                                        $('#ajax_update').html("<div id='message'></div>");
                                        $('#message').html(results)
                                        .append()
                                        .hide()
                                        .fadeIn(1500, function() {
                                        });
                                    }
                                });

Dalina,

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
 
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

Monday, November 29, 2010

Re: CakePlate - Boilerplate CakePHP distro

Looks very nice thank you.

Have you given any thought about ACL/Auth? Any plans on including that?


On Mon, 2010-11-29 at 20:16 -0800, ryan.pendergast@gmail.com wrote:
> You know how as a developer each time you create a new web app you
> spend the first few hours downloading, installing, and configuring the
> important add-ons that you need for nearly any production-level
> project? When all you really want to do is get started on your new
> kick-ass idea?
>
> That's why a friend and I decided to do something about it. We're
> launching CakePlate, a open source distribution of CakePHP that's
> ready to rock, right out of the box.
>
> learn more and read the full announcement at http://cakeplate.posterous.com/
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en


Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

Re: How do I Find Categories within in Contained Model in CakePHP

I have also posted this at Stackoverflow if you're interested

On 11/30/2010 1:23 PM, Thorpe Obazee wrote:
Hi Everyone,

I had a recent question here regarding Finding records via conditions in habtm. Now, I could search for posts within a category I searched for.

Now, my questions is how to I retrieve the categories of each post if it has two or more categories in this query:

$this->set('posts', $this->Category->find(     'first',     array(         'conditions' => array(             'Category.uri' => $uri         ),         'contain' => array('Post')     ) )); 

I'd imagine something like this:

$this->set('posts', $this->Category->find(     'first',     array(         'conditions' => array(             'Category.uri' => $uri         ),         'contain' => array('Post' => array(             'contain' => 'Category'         ))     ) )); 

Here's what my models look like.

// Category Model class Category extends AppModel {     var $name = 'Category';     var $hasAndBelongsToMany = array(         'Post' => array(             'className' => 'Post'         )     );     var $actsAs = array('Containable'); }  // Post Model     class Post extends AppModel {         var $name = 'Post';         var $hasAndBelongsToMany = array(             'Category' => array(                 'className' => 'Category'             )         );         var $actsAs = array('Containable');         var $virtualFields = array(             'date_posted' => 'DATE_SUB(Post.created, INTERVAL 7 DAY)'         );     } 

A sample data would be like this:

categories id name 1  holidays 2  destinations  posts id title 1  I am a post 2  I am another post  categories_posts post_id category_id 1       1 2       2 2       1 

I am retrieving posts from the Category, 'holidays'.

Array (     [Category] => Array         (             [id] => 3             [name] => holidays             [uri] => holidays             [created] => 2010-11-25 20:43:03             [modified] => 2010-11-25 20:43:03         )      [Post] => Array         (             [0] => Array                 (                     [id] => 1                     [title] => I am a post                 ),             [1] => Array                 (                     [id] => 2                     [title] => I am a another post                 )         ) ) 

The problem is that 1 of the posts are in two categories. I'd like to have that information also available so that I can show this in the view

/categories/view/holidays 
I am a post categories: holidays, destination I am a body text 

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
 
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en


How do I Find Categories within in Contained Model in CakePHP

Hi Everyone,

I had a recent question here regarding Finding records via conditions in habtm. Now, I could search for posts within a category I searched for.

Now, my questions is how to I retrieve the categories of each post if it has two or more categories in this query:

$this->set('posts', $this->Category->find(     'first',     array(         'conditions' => array(             'Category.uri' => $uri         ),         'contain' => array('Post')     ) )); 

I'd imagine something like this:

$this->set('posts', $this->Category->find(     'first',     array(         'conditions' => array(             'Category.uri' => $uri         ),         'contain' => array('Post' => array(             'contain' => 'Category'         ))     ) )); 

Here's what my models look like.

// Category Model class Category extends AppModel {     var $name = 'Category';     var $hasAndBelongsToMany = array(         'Post' => array(             'className' => 'Post'         )     );     var $actsAs = array('Containable'); }  // Post Model     class Post extends AppModel {         var $name = 'Post';         var $hasAndBelongsToMany = array(             'Category' => array(                 'className' => 'Category'             )         );         var $actsAs = array('Containable');         var $virtualFields = array(             'date_posted' => 'DATE_SUB(Post.created, INTERVAL 7 DAY)'         );     } 

A sample data would be like this:

categories id name 1  holidays 2  destinations  posts id title 1  I am a post 2  I am another post  categories_posts post_id category_id 1       1 2       2 2       1 

I am retrieving posts from the Category, 'holidays'.

Array (     [Category] => Array         (             [id] => 3             [name] => holidays             [uri] => holidays             [created] => 2010-11-25 20:43:03             [modified] => 2010-11-25 20:43:03         )      [Post] => Array         (             [0] => Array                 (                     [id] => 1                     [title] => I am a post                 ),             [1] => Array                 (                     [id] => 2                     [title] => I am a another post                 )         ) ) 

The problem is that 1 of the posts are in two categories. I'd like to have that information also available so that I can show this in the view

/categories/view/holidays 
I am a post categories: holidays, destination I am a body text