cakephp-1.3

Cakephp How to validate my D.O.B field so that the age will not be greater than the period of residence entered

只愿长相守 提交于 2019-12-08 04:52:48
问题 i have two fields in my form that should correspond to each other.If a users enters the date of birth,in the D.O.B field,he/she must not be allowed to enter a period of residence greater than the D.O.B my two fields in the add.ctp are as follows echo $this->Form->input('DOB',array('label' => 'Date of birth*', 'minYear' => 1900, 'maxYear' => 2000)); echo $this->Form->input('period_of_residence', array('label' =>'Period of residence in Zimbabwe')); So now i don't know how i validate the two so

Paginate results filtered by condition on associated model (HABTM) using Containable

橙三吉。 提交于 2019-12-08 03:04:07
问题 I need to paginate list of Product s belonging to specific Category (HABTM association). In my Product model I have var $actsAs = array('Containable'); var $hasAndBelongsToMany = array( 'Category' => array( 'joinTable' => 'products_categories' ) ); And in ProductsController $this->paginate = array( 'limit' => 20, 'order' => array('Product.name' => 'ASC'), 'contain' => array( 'Category' => array( 'conditions' => array( 'Category.id' => 3 ) ) ) ); $this->set('products', $this->paginate());

CakePHP Routing - [home]/slug as URL

给你一囗甜甜゛ 提交于 2019-12-07 21:52:38
问题 I'm trying to get to grips with Cake's routing, but I'm having no luck finding a solution to my particular problem. I want to map www.example.com/slug to www.example.com/venues/view/slug, where slug is the URL friendly name of a record for a particular venue. I also want to then map www.example.com/slug/events to www.example.com/events/index/venue:slug. After reading the CakePHP documentation on Routing, a few times over, I'm none the wiser. I understand how I would create these routes for

about HMVC in codeigniter and cakephp?

你。 提交于 2019-12-07 18:26:10
问题 i heard today from my friend about HMVC in codignitor..i surprise for this feature..it is very helping in the big projects .. and i am Sad because i cant found any article or anything tell me there are HMVC in cakephp..so i have two questions.. Anyone have idea for HMVC in cakephp? Is these Brings me to learn codignitor ? Do the plugins, such as HMVC? login example in codignitor HMVC <?php hmvcExample/application/modules/login/controllers/ hmvcExample/application/modules/login/models/

Deleting HABTM Association Record

只谈情不闲聊 提交于 2019-12-07 12:41:51
问题 I have two models, Posts and Tags. Posts HasAndBelongsToMany Tags. Let's say a Post 1 has the tags world, news, and paper. Now in the joining table, I want to remove the association between the Tag "paper" and Post 1, but the Tag "paper" should not be deleted from the tags table. Only the association in the joining table should be deleted. How do I do this in CakePHP? 回答1: When you do any HABTM operation other than adding a new one, Cake deletes and recreates the associated join table rows.

CakePHP Delete Cookie Issue

左心房为你撑大大i 提交于 2019-12-07 08:27:15
问题 I've browsed through other people's issues similar to this, but nothing seems to be exactly like what I am experiencing. Please feel free to reference me to another article if this has been addressed before. I have written a cookie when a user authenticates that stores some basic user info locally. When the user logs out, I am trying to delete the cookie variable, but is does not delete. If I use the destroy method, then the cookie is removed, but I am curious as to what I am doing wrong here

how do you create a select with both value and the label the same from an array in cakephp?

一世执手 提交于 2019-12-07 07:25:13
问题 I created an array in the controller from a table : $tasktemplateResults = $this->Tasktemplate->find('list'); And in the view I have a form helper that creates a drop down list: echo $this->Form->input('Tasktemplate.id', array('options' => array($tasktemplateResults),'label' => 'Task')); The html output is as follows: <div class="input select"> <label for="TasktemplateId">Task</label> <select name="data[Tasktemplate][id]" id="TasktemplateId"> <option value="1">Test task</option> <option value

How can I assign an id and class with $this->Html->link(..);?

你。 提交于 2019-12-07 03:42:14
问题 echo $this->Html->link( 'more', array( 'controller'=>'posts', 'action'=>'view', $post['Post']['id'] ) ); How can I assign an id and class for this anchor/link? I want to override its css rule. 回答1: HTML attributes can be specified in an array as the third parameter. echo $this->Html->link( 'more', array( 'controller'=>'posts', 'action'=>'view', $post['Post']['id'] ), array( 'id' => 'myId', 'class' => 'myClass' ) ); More info in the Cookbook 2.x for the 2.x version or Cookbook 1.3 for CakePHP

CakePHP GROUP and COUNT items returned in list

余生颓废 提交于 2019-12-07 03:02:00
问题 I know there are some similar quesiton like this on here but they are all about when using Model->find('all'); But thats not what I am doing, I am doing: Model->find('list'); Which is whats making the difference between this working and not working. Given a group of Products I want to find all the brands in that group and how many of each brand. Sounds simple enough, here is what I did: $fields = array('Product.brand','COUNT(`Product`.`brand`) AS brand_count') $brand_data = $this->Product-

CakePHP find with MAX

守給你的承諾、 提交于 2019-12-06 21:11:04
问题 Tables and dummy data: CREATE TABLE IF NOT EXISTS `messages` ( `id` int(11) unsigned NOT NULL auto_increment, `user_id` int(11) unsigned NOT NULL, `node_id` int(11) unsigned NOT NULL, `reciever_id` int(11) unsigned NOT NULL, `created` datetime default NULL, `modified` datetime default NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=9 ; INSERT INTO `messages` (`id`, `user_id`, `node_id`, `reciever_id`, `created`, `modified`) VALUES (1, 1, 1, 15, '2011-12-07 00:00