You have to use $this->Model->bindModel() to help cake with the joins:
http://book.cakephp.org/view/83/hasAndBelongsToMany-HABTM
has some examples further down the page.
On Apr 1, 4:05 pm, Zac Tolley wrote:
> I've done complex selection before, the difference here is that is
> seems to split th
300kb sounds very large for even a complex controller.
Don't forget: Fat Model, Skinny Controller
Move all your controller queries into the model as methods, that
should slim down the controllers a bit
On Apr 1, 1:27 pm, euromark wrote:
> sure
> i did that with the user controller (used to be >
A good rule of thumb is: anything that is shared between all pages
goes in the layout
On Mar 30, 3:10 pm, Jeremy Burns wrote:
> My opinion... I think these tags belong inside the layout, and have layout
> tags (div etc) in the view so that they appear inside the body tags rendered
> by the layo
It looks like the ':' delimiter is set in /cake/router.php around line
99:
var $named = array(
'default' => array('page', 'fields', 'order', 'limit',
'recursive',
'sort', 'direction', 'step'),
'greedy' => true,
'separator' => ':',
I'm with WebbedIT on this one.
And besides, you can always do something like the following in your
controller:
$data = $this->Article->read(null, $id);
$article = $data['Article'];
$this->set(compact("article", "data"));
and access $article['name'] etc. in your view.
On Mar 24, 7:52 pm, Lucas
Anyone got any ideas as to why I don't get the validation errors from
HABTM relationships mentioned above?
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
"
view is empty.
Is this a bug? I see that Mark Story has been doing some work on
something related (
http://cakephp.lighthouseapp.com/projects/42648/tickets/65-additional-fields-on-habtm-join-tables-wont-get-properly-validated
) and my version of CakePHP has his changes incorporated.
On Feb 15
"Tag.0.PostsTag.weight")?>
input("Tag.1.PostsTag.tag_id", array("options"=>
$tags))?>
input("Tag.1.PostsTag.weight")?>
end("Submit") ?>
On Feb 16, 11:01 am, "rich...@home" wrote:
> Many thanks for the reply. I
Many thanks for the reply. I've successfully managed to get my HABTM
models saving its extra field.
Just for the record, if anyone else is looking for the answer:
class Post extends AppModel {
var $hasAndBelongsToMany = array(
"Tag"=>array(
"with"=
Hi all.
I'm trying to get my head around HABTM associations with extra fields
in the join table, but without much success.
So, its confessional debugging time :-) I'm using latest stable
release of Cake 1.2.6.
Here's what I have so far...
My understanding is that if I want to use additional fie
You could put your flash front in in the root (www.mydomain.com) and
then install cake at www.mydomain.com/intranet
On Feb 9, 1:20 pm, VitillO wrote:
> Hello, im kinda new in Cake, i've always been developing Flash sites
> and now im using Cake for the backends (or CMS) for this sites. But im
> h
Never mind, found it :-)
For anyone else looking for the answer here it is...
In model:
function foo() {
$Setting = ClassRegistry::init('Setting');
$first_class_cost = $Setting->findValue("1st Class");
}
On Feb 4, 4:50 pm, "rich...@home" wrote:
> H
Hi all.
I have a stand-alone (not associated with any other model) Setting
model that contains key/value pairs containing user editable values
used throughout my app (VAT rate, postal costs etc.)
I'd like to get at this Setting data inside another model method
(Order::calculateTotal() for example
Are you using IE? And making Ajax calls? or launching applets?
I had this problem for the last few days.
The fix is to set
Configure::write('Session.checkAgent', false);
in core.php
The reason is: IE sometimes uses a different user agent string when
doing ajax calls, and so will any ap
Seems the edit form multi-select for HABTM relationships doesn't
populate previously selected options as it does in 1.2.5.
The selected values are in the data returned by Model->read() but the
form doesn't show them as selected.
Check out the new CakePHP Questions site http://cakeqs.org and help
or alternatively:
create("Model", array("action"=>$this->action)) ?>
On Sep 29, 8:11 pm, "euromark (munich)"
wrote:
> this is the correct way to go:
>
> echo $form->create('Model',array('url'=>'/'.$this->params['url']
> ['url']));
>
> On 29 Sep., 15:00, Django Janny wrote:
>
>
>
> > I think yo
AppController doesn't go in the cake/ folder, it goes in your app
folder:
/app/app_controller.php
class AppController extends Controller {
var $helpers = array("Html", "Form", "Javascript");
}
On Sep 30, 9:17 am, lorenx wrote:
> m, ok...
> i raised the issue just because the cookbook sa
No, you only want to translate the label, not the field name :
echo $form->input("field_name", array("label"=>__("field_name")));
On Sep 25, 9:19 am, emmexx wrote:
> On 25 Set, 02:18, brian wrote:
>
> > __('field_name')
>
> Do you mean that I can use in a view something like the following?
>
>
I wrote one a while back and posted it to this group. can't seem to
find it now, but here's a link to it stored elsewhere:
http://markmail.org/message/nleqrkgtm2ji6sfe
On Sep 14, 11:10 am, Shaun wrote:
> I have a table called comment_ratings where users can rate comments up
> or down. It look
Just to clarify mike's point:
in your controller:
$conditions = array("Property.zip" => $this->data);
should be:
$conditions = array("Property.zip" => $this->data['Property']
['zip']);
On Aug 26, 10:15 pm, mike karthauser wrote:
> hi
> you should turn on debug=2 and have a look at your query
Also worth remembering to clear the app/tmp directories (just the
files, leave the directory structures intact) when you upload
On Aug 21, 9:22 am, Bert Van den Brande wrote:
> I've had blank pages when :
> * .htaccess was not working as it should, due to restrictions from
> Apache (it needed Al
Jonathan Snook posted some very useful code to add this functionality:
http://snook.ca/archives/cakephp/multiple_validation_sets_cakephp/
Works like a charm :-)
On Aug 20, 5:58 pm, DavidH wrote:
> Hi
>
> Is there a simple way to do this? I have a UsersController and User
> method that does a d
}
>
> This works! I just can't say how much I am grateful for your help!
> However I still don't understand why my code was wrong...
>
> About your second way:
>
> $post = $this->Post->read(null, $var);
> $post['Post']['options'] = value1;
>
Shouldn't that be:
foreach($posts as $p) {
if ($p['Post']['id'] == $var) {
$p['Post']['options'] = value1;
} else {
$p['Post']['options'] = value 2;
}
$this->Post->save($p);
}
also, if you are just matching against the id, you could just writ
or...
'conditions'=>array(
"Bar.created' >= (NOW() - interval '7 days')"
)
On Aug 19, 6:23 am, Elmo wrote:
> I would like to use the built in database date/time functions as part
> of a 'conditions'. How is this done?
>
> i.e.: select foo from bar where created >= (NOW() - interval '7
> day
You can find out the location of the php.ini file your setup is using
by creating a php page somewhere with the following line:
wrote:
> If you had no configuration file your server wouldn't work.
>
> It will be called php.ini and could be located in any number of places
> depending on exactly w
Any value you like, usually something unique to your site. A random
sequence of numbers/text is usually recommended.
It's used as a 'seed' for the various hashing functioned used in
CakePHP.
On Aug 14, 9:20 am, Arun VS wrote:
> Hi all members i am new to Cake PHP. I had installCake PHP 1.2.4.82
Not out of the box, no.
There's nothing stopping you creating a ColourPickerHelper of your own
though.
On Aug 12, 1:45 pm, DavidH wrote:
> Hi
>
> Is there any way of passing style settings for each select option when
> using $form->select?
>
> I've a drop down that allows users to choose a col
flash('auth'); ?>
http://book.cakephp.org/view/564/Displaying-Auth-Error-Messages
On Aug 2, 9:16 pm, brian wrote:
> Failed logins are not getting Auth's msg displayed. I've done this
> before but I'm about out of ideas why this isn'tworking. Can someone
> take a look at this and tell me what I
Here's a quick tutorial I posted on using containable with paginate:
http://richardathome.com/blog/cakephp-pagination-containable
On Jul 29, 3:17 pm, JamesF wrote:
> well to answer your question about paginate and containable, you can
> set 'contain' paramaters on $paginate along with conditio
I'd use a drop down select instead of an option group.
This should do the trick:
input("Model.field", array("options"=>array(""=>"No
information on subject", true=>"True", false=>"False))); ?>
On Jul 29, 12:29 pm, Kanten wrote:
> Is there really noone, that can help me with this one?
>
> Than
Sorted it... I'd made a tiny modification to cake core (dbo_source) to
fix another issue.
Note to self: Serves you right!
On Jul 28, 11:25 am, "rich...@home" wrote:
> Bit of an odd one this, and it has only started happening recently in
> an application I'm buildin
Bit of an odd one this, and it has only started happening recently in
an application I'm building...
I'm using CakePHP 1.2.3.8166
The following validation rule:
var $validate = array(
"name"=>array(
"required"=>array(
There's Drake (Drupal CakePHP Bridge) but it hasn't been updated in a
long time and there's no port for Drupal 6 :-(
http://dev.sypad.com/projects/drake/
Other than that, what exactly are you trying to achieve?
On Jul 23, 8:30 am, leon zhang wrote:
> does anyone try to use cakephp with drupal?
It's worth noting that binp's code will return the mac address of the
SERVER, not the client requesting the page.
On Jul 18, 6:54 pm, bino dev wrote:
> HiDeeps,
>
> Chk out this code.
> ob_start(); // Turn on output buffering
> system(’ipconfig /all’); //Execute external program to display outp
Should be:
var $validate = array(
"module_data" => array(
"module_dataRule1" => array(
"rule" => "notEmpty",
"message" => "empty",
"required" => true
no need to use different directories :-)
Check out 'admin routing' in the docs:
http://book.cakephp.org/view/544/Prefix-Routing
This enables you to make special views for your administrators. For
example, the views for a post controller would look like:
app/views/posts/
admin_add.ctp
admin_edi
"What kind of field are you using to store HTML?"
As your new to MySQL its worth emphasising that text fields with the
datatype of varchar have a maximum length. Your data may be getting
truncated as it's too long to fit in the varchar field.
Have you tried increasing the size of the field in th
$this->data['Resource']['ID']=1000;
should be:
$this->data['Resource']['id']=1000;
(Models are CapitalisedNoSpaces, fields are all lowercase_underscore)
On Jul 3, 6:03 am, sajjan wrote:
> Thank you Miles!
>
> Hmm.. I had tried this and it did not work,but if I put both the lines
> below toget
I was thinking about this the other day.
There are a few validation rules I use in pretty much every
controller, such as 'required'. The following *should* work
(untested):
in AppModel:
var $rule['required'] = array(
"rule"=>array("minLength", 1),
"message"=>"cannot be blank",
"requ
CakePHP is still PHP, header() works just fine :-)
On Jun 29, 8:49 pm, "Techinfocomp.com" wrote:
> header("refresh:5; url='pagetoredirect.php'");
>
> we can use this if we want to redirect our page in 5 second ,
>
> is there any way to redirect page in 5 second in cakephp ?
>
> if yes please let
Forget about storing the id in a session and just include the field in
the form. Cake will automatically hide it from the user.
On Jun 18, 8:55 am, Jon Chin wrote:
> I'm building a scholarship application using Cake. I have an
> Application model and a Merit model and I'm using a wizard compone
*Might* be an out of memory error:
Try increasing the size that PHP is allowed to consume in your php.ini
file. You will need to restart Apache for the change to be registered.
Search for "memory_limit" (without the quotes).
*Might* be a cached path problem:
delete all the files in the app/tm
I got this working using AJAX using this bakery article as a starting
point:
http://bakery.cakephp.org/articles/view/easy-ajax-pagination-using-jquery
On Jun 5, 1:24 pm, Cjo wrote:
> Hi all,
>
> I have requirement where I have to show two paginated list in the User
> Home page.
>
> I have bee
or alternatively (not tested, may not work), create a subscribers
folder in elements:
app/
views/
elements/
subscribers/
subview1.ctp
subview2.ctp
and in your view:
element("subscribers/subview1); ?>
That way you'll keep your subviews whi
I think the way CakePHP handles the delete links is very bad practice
tbh. The delete action should be through a POST not a get. Also,
protecting it with Javascript doesn't help if your site is being
spidered...
A better approach is to create your own delete($id) method
AppController (so its avai
Looks like development has stalled on Drake, it doesn't support the
latest version of Drupal :-(
On Jun 4, 6:20 pm, jwerd wrote:
> I am curious if anyone has used the new CakePHP 1.2.3.8166 Stable with
> Drake, or rather, is it still the solution to combine Cake with
> Drupal?
>
> TIA
> Jake
--~
Are you using IE?
IE has an annoying habbit of caching ajax responses, and the only
reliable way to get round it is to append a random string to the end
of the request url as an additional parameter.
/controller/model/param1/param2/my_random_param/
On Jun 2, 5:59 am, "Dave Maharaj :: WidePixels
or count($this->data['Entry'])
On May 29, 4:13 am, Marcelo Andrade wrote:
> On Thu, May 28, 2009 at 11:05 PM, Dave Maharaj :: WidePixels.com
>
> wrote:
>
> > Whats the easiest way to count the number of items in an array? I use the
> > data in the array so its more than just a count.
>
> > I si
If you are using the Auth component, Auth will hash the blank
password.
The workaround I've found for this is to use a dummy password field
(e.g. new_password) instead of the real password field, then in your
controller::save() do
if (!empty($this->data) {
if (!empty($this->data['Model']['n
I'll try and get a test case done at work tomorrow. That said, I've
never written a unit test before but I can post the code required to
duplicate it easily...
On 28 May, 17:51, Gwoo wrote:
> test case? this could be a problem with the proper defaults not being
> set for the table.
--~--~---
Close, it should be:
postOfTheMonths
:-)
On May 28, 9:11 am, fain182 wrote:
> > I'm having some trouble figuring out what the problem is here. Could
> > you clarify why you want a variable name with spaces?
>
> ok, i want to have a form->input() that make me a select, for example,
> if the fie
eing cast from a null to a string somewhere before
this code is being executed and the absolutely equal (===) is failing
because the datatype of a null string is different to the null its
being compared to.
Should I ticket this?
On May 28, 3:22 pm, "rich...@home" wrote:
> In the mod
Sorry, should have made that a bit more clear:
The value is coming from a form posting. The value is a PHP null in
the form post array so the condition is actually:
$price = $this->Price->find("first", array(
"conditions"=>array(
"Price.product_id"=>$data['OrderDetail']['
In the model:
$this->find("first", array(
"conditions"=>array(
"OrderDetail.id"=>""
)
;
Produces the following SQL where clause:
WHERE `OrderDetail`.`id` = NULL
That will never match any records (comparing anything directly with
NULL always results in NULL,
Still struggling with this one. After a bit more rigorous testing the
above doesn't work :-(
Anyone who has fixed this issue want to share their wisdom? :-)
On May 14, 4:39 pm, "rich...@home" wrote:
> After even more testing:
>
> Add the following to Ap
No, you can't. If you remove them you will get a controller not found
error when you go to your bookmarks pages
On a side note, you can remove the $uses line as CakePHP automatically
adds the model associated with the controller (unless your
AppController explicitly sets $uses = array() )
On May
One minor niggle-ette for me:
I hate how form helpers $form->create() doesn't default to the current
actions (it defaults to add). I always end up having to type:
create("User", array("action"=>$this->action)) ?>
oh, and another:
$html->css() defaults to inline, it should default to putting it
$data = $this->Model->find("all", array(
"conditions"=>array(
"RelatedModel.field"=>$value
)
));
?
On May 20, 7:55 pm, programguru wrote:
> My situation is simple, but I have yet to find a solution that actually does
> what I need.
>
> And I am not sure at what level the data requirements shoul
de(urlencode($value));
}
Fixes the pagination links
Brain too tired to worry about the long term problems this might
introduce right now...
On May 14, 4:06 pm, "rich...@home" wrote:
> Edit after more testing:
>
> Still not good, paginator links doen't
Edit after more testing:
Still not good, paginator links doen't double encode so it breaks when
a pagination link is clicked :-(
On May 14, 3:42 pm, "rich...@home" wrote:
> More investigation: There's a related ticket open:
>
> https://trac.cakephp.org/ticket/
}
}
return $url;
}
- takes posted form data and returns a url array suitable for passing
into $this->redirect($url);
On May 14, 3:08 pm, "rich...@home" wrote:
> I'm back trying to fix this issue and it's starting to be a bit of a
> p
I'm back trying to fix this issue and it's starting to be a bit of a
pain :-(
This is definitely a problem with the default CakePHP setup because if
I create a simple php file:
index.php:
http://example.com/index.php?a=%
and don't get a bad request (even though technically it IS a malformed
url)
It sounds like they have a dev version of the site tucked away in the
webroot.
Live site -> http://www.example.com/
Dev site -> http://www.example/com/dev/
On May 12, 2:56 am, Braydenstyles wrote:
> my previous devs had a working website live for us but now the devs
> are gone and i've been tr
If you don't want to add them by hand ever time. I've written a
function that will do it for you:
http://www.richardathome.com/blog/cakephp-auto-populating-foreign-key-dropdown-fields
On May 8, 3:16 pm, brian wrote:
> Did you fetch a list of Users in your controller? FormHelper can only
> work
link("http://www.google.com/jsapi";);
echo $javascript->codeBlock("google.load('jquery', '1.2.3');");
?>
or alternatively:
link("http://jqueryjs.googlecode.com/files/
jquery-1.3.2.min.js") ?>
On May 8, 10:35 am, dnoop wrote:
> I just wanted to load jquery from google like
>
> http://www.goo
Define your criteria for 'best' ;-)
On May 8, 12:41 pm, Sarika wrote:
> Hi Friends,
>
> Which PHP framework is the best? Symfony or CakePHP
> What are the advantages and disadvantages over one another.
> All of you, please share your opinion.
> Thank you.
>
> Regards,
> Sarika
--~--~-~--
Can you post your form code and controller action code?
On May 7, 1:06 pm, lucas wrote:
> Hi, i have this problem that is killing me slowly jeje, in my view a
> have about 14 or 15 hidden inputs cause i need them in the edit
> action. But when i submit the page, one of them is not submitted and
You can pre-populate the $this->data array:
In your controller method:
$this->data['Model']['field'] = 1;
(where 1 is value you want to pre-select)
or,
in the view:
input("field", array("options"=>$options, "default"=>1) ?
>
On May 4, 9:56 pm, qwanta wrote:
> In the controller I do a find(
You'll need to post your code before anyone has a hope of helping you
here ;-)
On May 5, 6:13 am, programguru wrote:
> does anyone know why the values being pulled into my index view are id values
> as opposed to the literal string value of the field?
> --
> View this message in
> context:http:
"need the opposite: IF the field is present, it must NOT be empty
(and it must be unique). "
IF it doesn't have to be present, its NOT a required field ;-)
To make CakePHP add the required classes you must include the addition
rule "required"=>true
e.g.
var $validate = array(
'name' => array
If I remember correctly, the ARO/ACO tables are not indexed by default
(this may have changed in later versions of cake).
On Apr 25, 10:08 pm, Miles J wrote:
> Make sure you have indexes set on your database.
--~--~-~--~~~---~--~~
You received this message because
I've got tinymce working in a cake app, but I didn't put the code in
/app/plugins/content/vendors/j s/tiny_mce
I put it in
/app/webroot/js/tiny_mce
On Apr 26, 3:49 pm, Evert wrote:
> When I create a link to tiny_mce.js the javascript file is found, no
> problems there.
> But when I initialize
See my solution to an allmost identical problem:
http://groups.google.com/group/cake-php/browse_thread/thread/51aec944f860a708/89496a7d5f64542a?q=#89496a7d5f64542a
On Apr 27, 10:48 am, Telegu wrote:
> nobody can help me?
>
> On Apr 18, 4:02 pm, Telegu wrote:
>
> > yes to save my data correctl
You don't need contain, unless you want the post data too:
$this->Post->Subject->find("all", array(
"conditions"=>array(
"Subject.post_id"=>$post_id
)
);
If you do need the post data, brian's solution should work just fine.
On Apr 25, 5:21 am, brian wrote:
> This doesn't work?
>
> $thi
I downloaded the 5.1 Beta OSS and installed the plugin.
Created a schema no problems, but only for copying to the clipboard
(no biggy tbh) :-)
Unfortunately, there seems to be a bug in 5.1(not the plugin) that
stops exports from producing inserts (for inital seeding of the
database). So its bac
I never even KNEW there was a CakePHP plugin for WB!
Damn, that's going to save me even more time! :-)
On Apr 23, 3:01 pm, Karsten Wutzke wrote:
> I'm referring to
>
> http://forums.mysql.com/read.php?155,258646,258824#msg-258824
>
> The CakePHP plugin for MySQL Workbench is supposed to be wor
Looks good.
All I can suggest is to triple check you've named your files correctly
(case matters) and put them in the correct place.
On Apr 13, 7:21 pm, Beedge wrote:
> Hi all.
> I recently decided that I got to get trained up in using a php
> framework as up till now Ive been handcoding everyt
I'm guessing you still have all the old directory information cached.
go to app/tmp/ and remove all the files in all the subfolders but
leave the subfolders intact.
On Apr 11, 12:58 pm, AD7six wrote:
> On Apr 11, 12:36 pm, CapeTownGuy wrote:
>
> > Hi,
>
> > I installed an application in the ro
In my AppController, I set a bunch of view variables in the
beforeFilter() {} callback.
I use these view variables ($authUser) in the layout to for e.g. a
welcome block.
If the user goes to a page that doesn't exist, then AppController
isn't loaded at all and these view variables aren't populat
It's getting passed by a form search form submission as a GET request.
On Apr 4, 12:12 am, Miles J wrote:
> Why is the % there in the first place?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To
Yup, I know it should be url encoded. But if you URL encode it, it
STILL produces a 400 error because it STILL contains a '%'
Strange that the only CakePHP site that I can find that copes with it
without an error is the CakePHP website.
http://cakephp.org/pages/%
So, what are they doing right t
If your original post doesn't get any attention it may be because the
problem hasn't been explained well enough for someone to help.
There's nothing stopping you coming back to a question to add a bit
more clarification :-)
This also has the added benefit that sometimes, as you clarify the
probl
You can use your own validation functions in your model for this:
class Article extends AppModel {
var $validate = array(
"name"=>array(
"rule"=>"myRule",
"message"=>"you failed myRule!"
)
);
function myRule($data) {
// $data contains the value of 'name'
// $t
How to do validation without a database table:
You still need a model. For a concrete example, check out Snook's
CakePHP contact form: http://snook.ca/archives/cakephp/contact_form_cakephp/
Where to put common controller functions? Create a component.
Hope this helps
On Mar 5, 11:00 pm, D4rko
85 matches
Mail list logo