Delete only one associated record

2011-05-30 Thread emmexx
I have 2 models with a hasMany/belongsTo relation. Let's say User/
Pictures: a user hasMany pictures and a picture belongs to a user.

I have a page where it is possible to enter data about the user and to
select pictures and enter data about them.
The problem: when I try to edit the data I can choose to remove one
or many pictures.
Is there a cake way to accomplish that?
If I simply remove the picture from the page and save cake doesn't
delete anything. Should I do that by hand, coding some code that
checks if the submitted data is different from the recorded data?

Thank you
maxx

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Authentication using external users table

2011-05-26 Thread emmexx


On 24 Mag, 14:51, Rob Maurer robmau...@gmail.com wrote:
 Then it would seem the problem is adding authentication for users from
 another database table to existing CakePHP Auth/ACL. That's uncharted
 territory for me. One idea:

That is unchartered territory for me too.
The problem is that the solution you suggested is not worth all the
work necessary to accomplish it.

I need to authenticate a single page, I think it is easier to create
a one-time link (something like http://.../mypage/22h232g3283c23823c232).

Thank you
maxx

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Authentication using external users table

2011-05-22 Thread emmexx


On 22 Mag, 22:15, Rob Maurer robmau...@gmail.com wrote:
 If I understand your needs as written, it would seem simpler to stay
 with CakePHP Auth/ACL and create a second tier of permissions for a
 subset of Users who are also in the Users table. That would handle
 authentication for you (the way you're already doing) and you would
 grant those Users access to the create/update/delete views on your
 models as needed.

The problem is that the second group of users has its own table in
another database.
Those users are managed by another (non-cakephp) program and I'd
rather prefer not to mess with it.
Furthermore I would like not to manage permissions for those users.
They simply need to enter some data in a field, data not that
important.
And the more the 2 systems are separated, the better.

Anyway I'll think about your suggestion.

Thank you

maxx

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Authentication using external users table

2011-05-21 Thread emmexx
In one cake app I use Auth and Acl to authenticate users, as per
manual.
Now I need to let some users, not listed in users table but in another
database, edit the records of a table. Let's say for clarification
that they should manage their own profile.

What I want to do is:

1. let those users authenticate outside of my app Auth system.
I created a form where those users enter their username and password.
The form is public ($this-Auth-allowedActions = array('mylogin');

2. If their credentials are valid I redirect to a form (a view of the
model they have to edit).

Obviously I want to be sure that when the second form is submitted,
what the server receives is not faked. I mean, I need some kind of
persistence in order to verify that the submitted data comes from an
authenticated user and the data is consistent with the user (a user
can modify only his own profile).
To accomplish that is it enough to create a session key and check it
before saving data?
And what kind of complexity should I implement from a security point
of view? I mean, is it enough to set a simple session key ( e.g. $this-
Session-write('authenticated', true) ) ? Or should I write something
more complex (e.g.hashing of some user data?)
I'm not sure that php/cakephp Session component are enough to
guarantee that the submitted data is coming from the same user
previously authenticated.
Are there better cake methods to accomplish the same goal?

thank you
   maxx

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


cache duration and db updates

2010-10-11 Thread emmexx
I'm not sure I understood the working of the cache helper.
I mean, if the cache gets updated every time the related (model) data
chenges what's the point of the duration parameter?
Why should I want to refresh the cache every n seconds or hours or
days if cake updates the cache form me automagically?

Thank you
maxx

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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: How can I populate data belonging to TWO NON-RELATED TABLES in ONE Controller

2010-09-26 Thread emmexx


On 26 Set, 15:22, Divya Banik divya101...@gmail.com wrote:
 Or you can use ClassRegistry::init('ServerInfo')-find('all');

For the record the manual lists the cake way to load a model:

http://book.cakephp.org/view/67/Understanding-Models
http://book.cakephp.org/view/529/Using-App-import

bye
   maxx

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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


adodb and odbc support in 1.3

2010-09-25 Thread emmexx
I want to connect to an Access db on a a Vista pc (I have to, it is a
legacy app.)
I installed cakephp 1.3 and a datasource file found on the Bakery,
only to discover that the file depends on dbo_adodb and dbo_adodb is
missing in 1.3.
Odbc is missing too form 1.3. Should I stay with a 1.2 version of
cake?
Or can I copy the files from 1.2 to 1.3?

thank you
   maxx

OT: I installed xampp and easyphp on the aforementioned Vista pc and
I'm not satisfied. What wamp solution do you install on windows
(vista)? I don't want to waste hours managing permissions, paths and
other unknown parameters preventing apache from working properly.

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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: adodb and odbc support in 1.3

2010-09-25 Thread emmexx


On 25 Set, 11:04, Jeremy Burns | Class Outfit
jeremybu...@classoutfit.com wrote:
 What happens when you give it a go?

I did a very simple scaffold.
I copied dbo_adodb and dbo_adodb to model/datasources/...

The index page of a table works but if I try to load one of the
following (paginated) pages I get the following warning:

Warning (512): SQL Error: [Microsoft][Driver ODBC Microsoft Access]
Syntax error (missing operator) in the query 'OFFSET 20 [T1].
[id_persona]'. [CORE\cake\libs\model\datasources\dbo_source.php, line
681]

I never used OFFSET in a ms access query, it's not a reserved word.
OFFSET is used as an alternative to mysql LIMIT in
dbo_adodb_access.php.

I can live off without pagination in this particular application but
my question was: can I use reliably this driver or it is unsupported/
wrong/obsolete and query results are unpredictable? And does
association between models work properly?

Thank you
   maxx

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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: adodb and odbc support in 1.3

2010-09-25 Thread emmexx


On 25 Set, 17:09, emmexx emmeics...@gmail.com wrote:

 Warning (512): SQL Error: [Microsoft][Driver ODBC Microsoft Access]
 Syntax error (missing operator) in the query 'OFFSET 20 [T1].
 [id_persona]'. [CORE\cake\libs\model\datasources\dbo_source.php, line
 681]

Sorry I forgot to copy the query:

Query: SELECT  TOP 20 OFFSET 20 T1.id_persona ...

   maxx

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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: How can I populate data belonging to TWO NON-RELATED TABLES in ONE Controller

2010-09-25 Thread emmexx


On 25 Set, 03:24, Ancy DSouza ancyc...@gmail.com wrote:

 Now I want to populate the data of both the tables in my Members controller.

 Now Members table can be populated in Members controller as below.
 $table = $this-Member-query(SELECT members.id, members.name,
 members.email FROM members);


$this-loadModel('ServerInfo');
$server = $this-ServerInfo-find('all');

bye
   maxx

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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: hasOne relation with external database table

2010-09-21 Thread emmexx


On 12 Set, 10:13, emmexx emmeics...@gmail.com wrote:

 find('all') now gives no result.

 Is this the expected behaviour? There are limitations when relating
 models that belong to different dbs?
 I'm using cakephp 1.2.6.

Searching better in the Google archives I found out this thread:

http://groups.google.com/group/cake-php/browse_thread/thread/b542cf436cc8622f/6e6857aa813dc601?lnk=gstq=join+different+databases#6e6857aa813dc601

Short answer: it is not possible to join 2 models in different
databases.

maxx

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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


hasOne relation with external database table

2010-09-12 Thread emmexx
I don't know if the following behaviour is by design, a bug or I'm
missing something.

I have 3 models T1, T2 and T3 (the tables belong to the same database)

T1 hasOne T2
T1 hasOne T3

$this-T1-find('all', array('conditions'= array('T3.name' = null)))
gives:

Array
(
[0] = Array
(
[T1] = Array
(
[id] = 1
[name] = dog
)
[T2] = Array
(
[id] = 1
[t1_id] = 1
[name] = white
)
[T3] = Array
(
[id] =
[t1_id] =
[name] =
)
)
[1] = Array ...

If I move T3 to another database (I add var $useDbConfig = 'otherdb'
in T3.php and create the table of course) I get:

In the view:

Warning (512): SQL Error: 1054: Unknown column 'T3.name' in 'where
clause' [CORE/cake/libs/model/datasources/dbo_source.php, line 525]
Query: SELECT `T1`.`id`, `T1`.`name`, `T2`.`id`, `T2`.`t1_id`,
`T2`.`name` FROM `t1s` AS `T1` LEFT JOIN `t2s` AS `T2` ON
(`T2`.`t1_id` = `T1`.`id`)  WHERE `T3`.`name` IS NULL
As you can see the join between T1 AND T3 is missing.

find('all') now gives no result.

Is this the expected behaviour? There are limitations when relating
models that belong to different dbs?
I'm using cakephp 1.2.6.

Thank you
   maxx

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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


hasOne relation when primary and foreign key are the same

2010-09-10 Thread emmexx
I have to access some table created by others outside of cakephp.

2 of the tables are related by a hasOne relationship but the second
table has a primary key that is *the* foreign key. Please don't ask! :-
(
I can't change the tables.
I used the following models in cake:

table1:

class t1 extends AppModel {

var $name = 't1';
var $useDbConfig = 'other';
var $useTable = 'externalt1';

var $hasOne = array(
'T2' = array(
'className' = 'T2',
'foreignKey' = 'id',
'dependent' = false,
'conditions' = '',
'fields' = '',
'order' = ''
)
);
}

table2:

class T2 extends AppModel {

var $name = 'T2';
var $useDbConfig = 'other';
var $useTable = 'externalt2';
}

In the t1 controller I put a find('all'):
$this-log($this-T1-find('all')); // in index (just a test)

But when I go to T1s address I get a blank page and nothing in the log
file.

Is there a cake way to access the data of the 2 tables?

thanks
   maxx

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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: hasOne relation when primary and foreign key are the same

2010-09-10 Thread emmexx


On 10 Set, 20:08, cricket zijn.digi...@gmail.com wrote:

 That may be a fatal error. If PHP craps out it won't be able to log
 anything. Check your server's log.

Too lazy to check apache logs... :-(

PHP Fatal error:  Allowed memory size of 33554432 bytes exhausted
(tried to allocate 4198401 bytes) in /var/www/htdocs/cake/libs/
object.php on line 158

It was a find('all') without limits and conditions.

Thank you
maxx

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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


tree behaviour and validation rule problem

2010-02-02 Thread emmexx
I wrote a simple model that acts as a tree behaviour.
The model has a myfield_id field that must follow these rules:
- if parent_id is empty (root) myfield_id can't be blank
- if parent_id is not empty myfield_id must be blank (children)

So I wrote a isUnique validation rule for myfield_id. And it seems to
works if I use the baked add and edit pages.

Then I created another page that uses a javascript widget (tafelTree)
to show the tree and to drag and drop around nodes.
In the controller I created a function that receives the id and the
(new) parent id of a node as a parameter. If node id 1234 with
parent_id 5432 becomes (in javascript) a children of node 8765 my
function receives 1234-8765.
I retrieve the record with:
$category = $this-Category-find('first',
   array('conditions' = array('Category.id' =1234))
);
and try to save it with:
$ret =  $this-Category-save(array('parent_id' = 8765));

This fails with a validation error for the isUnique rule.
I put a log line in the isUnique function (in cake/lib.../model.php)
to see what is the condition that creates the error and...

(
[or] = Array
(
[Category.myfield_id] =
)

[Category.id !=] = 1234
)

But this is the same condition that I found when saving that record
using the edit function (with no error).
So I don't understand why there's a validation error when the
condition is the same.

Any suggestion?

Thank you

   maxx

p.s. En passent... the childrenCount function doesn't work properly
with my data. It reports a number of nodes greater than the real
number. I verified and reordered my data but the results of the
function are still wrong.

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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: tree behaviour and validation rule problem

2010-02-02 Thread emmexx

On 2 Feb, 15:45, John Andersen j.andersen...@gmail.com wrote:
 As I can't see your full code from the moment you retrieve the
 Category and until you try to save it, I can't be sure that you have
 provided the Category.id at the time of saving the updated parent_id.

 I just imagine that CakePHP actually may try to add a new record, in
 which case the isUnique should fail.

I developed my code starting from here:
http://realm3.com/articles/drag_and_drop_trees_with_cakephp
At the end of the page there's a save function and my code is almost
equal to that one.

$category = $this-Category-find('first', array('conditions' = array
(
   'Category.id' = $this_node_id)
));
$this-Category-set($category);
if (isset($category['Category']['id'])  $category['Category']
['parent_id'] !== $this_node_parent_id) {
$ret =  $this-Category-save(array('parent_id' =
$this_node_parent_id));
(the names of the variables are obvious.)

The original code used SetParent that, as you know, is deprecated
now.

I didn't use  $this-Category-id = 1234 before $this-Category-save
() because I presumed that find('first') would have the same effect
with the ActiveRecord approach. But I could be totally wrong on this.
And because, before adding the isUnique validation rule, my save
function did work.

Anyway, I just added $this-Category-id=1234; before $this-Category-
save() and the problem is still there. :-(

Thank you
maxx

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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


getparentnode and custom validation rule problem

2010-01-29 Thread emmexx
I wrote a model that act as a tree (mymodel).
In mymodel.php file I coded some custom validation rule.
One of the rules is like the following:

function testmyfield($check) {
   $grandfather = $this-getparentnode($this-data['Category']
['parent_id']);
   if ($grandfather)
   {
  $condition=array('Category.id' = $grandfather['Category']
['id']);
  $ret=$this-field('afield', $condition);
  if ($ret)
 return false;
   }
   return true;
}

When this validation rule gets executed $this-data changes after
getparentnode().
Before it is an array with the values entered in the form.
After it is an array like the following:

[Category] = Array
(
[parent_id] = 23
)

[P1] = Array
(
)

(P1 is a model related to Category)

The record gets saved with some of the (required and not empty) fields
empty. :-(

I don't understand if this can be a bug or if I'm doing something
wrong or in the wrong place.

Thank you
   maxx

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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Logout link in layout

2009-12-24 Thread emmexx
I'd like to put a logout link in my default layout. The link should be
there only when a user has already logged in.
I put the following code in my app/views/layouts/default.ctp:

if ($this-Auth-user())
echo $html-link('Logout', array('controller' = 'Users',
'action'='logout'));

but, of course, cake didn't like and screamed in horror:

Notice (8): Undefined property:  View::$Auth [APP/views/elements/
logout.ctp, line 3]

Fatal error: Call to a member function user() on a non-object in /app/
views/elements/logout.ctp on line 3

Is there a way to accomplish that?

Thank you and Merry Christmas!

   maxx

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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Passing (json) value to javascript in PHP4

2009-12-19 Thread emmexx

On 16 Dic, 11:29, Dave davidcr...@gmail.com wrote:
 do you have the latest pull from the git repo on both test and production
 servers?

I updated to 1.2.5 and the problem disappeared! :-)

Thank you for the suggestion.

   maxx

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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


i18n and multiple po files

2009-12-17 Thread emmexx
Since my yoga teacher told me to stop googling after the sixth page
I'm here asking for help (my yoga teacher is a sage woman but she
knows nothing about cake).

I tried to use i18n with a default.po file in an application and it
works.
Unfortunately with a single po file I can't get the best results, I
need different translations in different views.

So I found this article:
http://bakery.cakephp.org/articles/view/p28n-the-top-to-bottom-persistent-internationalization-tutorial
and tried what is suggested in comment #30. I had previously created
the multiple pot files with the console and translated them with
poedit.
The problem is that this doesn't work for me. Nothing gets translated.
I tried to put the code suggested in the aforementioned article in a
controller or controllers/app_controller.php to no avail.

I even put some logging code in i18n.php but nothing of what I
expected happens:
I18n::translate always gets called with a null $domain.
I supposed that setting the $domain variable in beforeRender would
force cake to look for a different po file but this is not happening
with my setup.
Any suggestion?

thank you
   maxx

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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Passing (json) value to javascript in PHP4

2009-12-16 Thread emmexx

On 16 Dic, 11:29, Dave davidcr...@gmail.com wrote:
 do you have the latest pull from the git repo on both test and production
 servers?

I'm using cake_1.2.3.8166 both on server and on my pc. Always in a
hurry, I had no time to upgrade to 1.2.5.
Do you think that upgrading could solve the problem?

Thank you
   maxx

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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Passing (json) value to javascript in PHP4

2009-12-15 Thread emmexx
I've been trying to pass a field value to javascript for the last 3
days with no avail.

First of all on my development pc I have php5. On my test/productin
server php4.

I put in the controller view function:

$tracks = $this-Track-find(
'all',
array(
'conditions'=array('Track.path_id' = $id,
'contain' = array('Track.gpstrack')
)
);
$this-set(compact('tracks'));

//Track.gpstrack contains a GML file (something like Gmaps KML files)

In the view.ctp file:
$tmp= var phptracks=.$javascript-object($tracks);
echo $javascript-codeBlock($tmp);

On my pc this works perfectly.
On the test server $javascript-object formats the $tracks array in a
different way. There's a different number of escape backslashes and
the javascript variable phptracks isn't even initialised. FF and
firebug error log report: missing } after property list.
I suppose this has something to do with encode_json() function missing
in php4 but I don't understand why there's such difference in escaping
the field value. I mean the variable seems to be formatted almost
perfectly for javascript, why those missing backslashes in php4? Is it
wrong or incomplete cakephp code?
Should I implement an encode_json() function for php4? Should I code
this in a completely different way?

Thank you
maxx

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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


javascript files loading order

2009-11-08 Thread emmexx

I use many javascript files in one application.
Some file is linked in the layout view, other are linked in a model
view.
Some of those files depend on the other (e.g.: file foo.js depends on
prototype).

The html file created by cake contains the script tags ordered in the
wrong way (1st foo.js, 2nd prototype) so I get some javascript errors.

Is there a way to force the loading order of javascript files?

thank you
 maxx
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Retrieve schema of model

2009-10-22 Thread emmexx

I need to retrieve the schema of the fields associated with a model.
I know there's the _schema property but I don't know how to access it.
The problem is I need the schema inside the controller and I want a
list of the fields of any of the models.

I'm creating a page where the user can select one of the models  and,
using ajax, another select box gets filled with the fields of that
model.

I used Configure::listObjects('model') to get the list of the models
but I don't know what to do now.

I tried with
loadModel($selectedModel);
$this-$selectedModel-_schema
but this syntax is wrong in php (and I don't know php classes well).
I can't use php 5 syntax.

Thank you for any suggestion.

maxx
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Retrieve schema of model

2009-10-22 Thread emmexx



On 22 Ott, 12:04, Jon Bennett jmbenn...@gmail.com wrote:

 The easiest way would be to use ClassRegistry::init('ModelName')-_schema;

 hth

It did help!
Thank you.

I had tried that but my code was messed up and it hadn't worked.

   maxx


--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Retrieve schema of model

2009-10-22 Thread emmexx



On 22 Ott, 12:28, emmexx emmeics...@gmail.com wrote:
 On 22 Ott, 12:04, Jon Bennett jmbenn...@gmail.com wrote:

  The easiest way would be to use ClassRegistry::init('ModelName')-_schema;

For the record:

This works with php5:
ClassRegistry::init('ModelName')-_schema;

With php4 use:
$obj = ClassRegistry::init('ModelName');
$fields = $obj-_schema;

bye
   maxx
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



HABTM extra-field and form syntax

2009-10-21 Thread emmexx

I read the many posts and articles on HABTM and extra-field but my
problem is a little bit more difficult (to me) than the simple
examples I found there.

I'd like to implement a system to evaluate some parameter.
The parameter has a model and is HABTM with the main model.
In the HABTM table I added an extra-field, rate and the values for
this field should be filled with the values coming from another model.
To simplify let's say that the form should be like the following (the
capital O is for a radio button):

- health: O bad - O good - O very good
- money: O bad - O good - O very good
- ...

Let's suppose that the rate field has fixed option (to fill the select
with options is not a problem).
health, money and so on come from the parameter table and I'd like the
rate value checked for that parameter to be saved in the extra field.
I tried but I don't know what is the correct syntax. Cake generates
html code different from the one used in the examples I found (teknoid
and Mariano Iglesias).

I tried with:

$i=0;
foreach ($parameters as $parameter =$v):
   echo $form-input('parameter.parameter.'.$i, array
('type'='hidden', 'value'=$parameter));
   echo $form-select('parameter.parameter.'.$i++.'.value',  array
('aa'='bad','bb'='good'));
endforeach;

with double or single model name and many other variation but no way.
$this-data in the controller is wrong of course, something like the
following:

[Parameter] = Array
(
[Parameter] = Array
(
[0] = Array
(
[rate] = aa
)

[1] = Array
(
[rate] = bb
)

)

)

Any suggestion?

Thank you
   maxx
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: hidden fields after validate error

2009-10-13 Thread emmexx



On 13 Ott, 06:33, Dr. Loboto drlob...@gmail.com wrote:
 You're doing it wrong (c)

 If you fill some field based on other field value, do it in controller
 if you already have 1st field value. That's all.

Your suggestions are very challenging but very useful.

Thank you
   maxx
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: hidden fields after validate error

2009-10-12 Thread emmexx



On 11 Ott, 06:55, Dr. Loboto drlob...@gmail.com wrote:
 Three ways:
 1. Re-run your JS.
 2. Do same logic when output form.
 3. When show/hide fields by JS, keep form state in some hidden field
 (s) and show/hide when output form based on its value(s).

I tried to use your suggestions and found many other problems... :-(

I have an add view with 2 select boxes.

Changes in the 1st select are observed by an ajax-observeField that
fires a function in the controller and fills the option part of the
second select (e.g. 1st select lists countries and second select lists
regions of the selected country).

This works when the view loads the 1st time.

If there's a validation error the 1st select is ok but the 2nd one is
not updated. This is ok, when cake reloads the form the 2nd select
option list is empty.
So I tried to start the observedField function by changing the
selected option in the 1st select using javascript and the load event.
Javascript changes the select value But the observeField routine
doesn't start.
Moreover if I try to change manually (not in code) the select value
the observeField function starts only the second time I select a
value, not the 1st one.

This is the relevant code of my add.ctp view:

$options = array('url' = 'update_select','update' =
'Model1Model3Id','type' = 'synchronous');
echo $ajax-observeField('Model1Model2Id',$options);

echo $javascript-codeBlock('function updateonReload()
{
var x= 
document.getElementById(Model1Model2Id);
//alert(x.selectedIndex);
var tmp=x.selectedIndex;
//x.selectedIndex=0;
x.selectedIndex=tmp;
}');

echo $javascript-event('window','load','updateonReload()');

I'm a little bit lost...

Thank you
   maxx

--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: MultivalidatableBehavior problem

2009-10-12 Thread emmexx


On 11 Ott, 06:58, Dr. Loboto drlob...@gmail.com wrote:
 ALWAYS do such things just before actual save/validate.

ok, thank you.

 And provide
 all relevant code if you want real help.

I thought I did it... :-(

Another problem I found out using this type of validation is that the
required field tagging is lost.
Is there a way to rerender the view after changing the validate
fields?
I mean, I select a value from a select box and, depending on the
value, other fields become required or not required. Is there a way to
reload the view without losing the values already entered by the user?
Or cakephp is of no help here and I should code some prototype
function to add/remove the required class from the fields?

Thank you
   maxx
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: MultivalidatableBehavior problem

2009-10-10 Thread emmexx

On 9 Ott, 22:54, emmexx emmeics...@gmail.com wrote:

 So I suppose that  $this-validate is reset (by whom)? in between
 update_div() and beforeValidate().
 Or $this-Mymodel-setValidation('myrules') sets the wrong validate
 variable.

I moved the $this-Mymodel-setValidation('myrules') line to the add
function of the controller and it works.
I don't know why but I don't have enough spare time to investigate
now.

   maxx
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



hidden fields after validate error

2009-10-10 Thread emmexx

I'm using javascript and ajax to show/hide fields in a form depending
on the selected values of one or more fields.
The user chooses a value from a select and some other field is shown
or hidden.

When the user submits data and there's a validation error the form
reloads and the visibility value of the fields is lost.

Is there a cake way to reload the form the right way or I have to
rerun all the javascript code that checks values and hides/shows
fields?
(I know, I'm asking too much from cakephp...)

Thank you
   maxx
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



MultivalidatableBehavior problem

2009-10-09 Thread emmexx

I'm trying to use Dardo Sordi MultivalidatableBehavior (http://
bakery.cakephp.org/articles/view/multivalidatablebehavior-using-many-
validation-rulesets-per-model).

I have a Model with different rules depending on the value of a field
(a select box).

The select box is monitored by ajax-observeField and when the select
changes other fields are shown or hidden. In the controller there's a
function where I put the code to change the validation rules:

function update_div()   {
if(!empty($this-data)) {
Configure::write('debug', 0);

if ($options!='')
{
$this-log('val ferrovie1');
$this-log($this-Cycleway-validate);
$this-Cycleway-setValidation('ferrovie');
$this-log('val ferrovie2');
$this-log($this-Cycleway-validate);
}
else
$this-Cycleway-restoreDefaultValidation();
}
}

--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



MultivalidatableBehavior problem

2009-10-09 Thread emmexx

I'm trying tu use Dardo Sordi MultivalidatableBehavior (http://
bakery.cakephp.org/articles/view/multivalidatablebehavior-using-many-
validation-rulesets-per-model).

I have a form where, depending on the value of a field (a select box),
I want to validate one or another field.

The select box is monitored by ajax-observeField that, on a change
runs a function in the controller:

function update_div()   {
if(!empty($this-data)) {
//code to find something (omitted). The result
in $options
if ($options!='')
{
$this-Mymodel-setValidation('myrules');
}
else
$this-Mymodel-restoreDefaultValidation();
}
}

myrules and the default rules are defined in the model. The default
rules work as expected, myrules don't.
I tried to trace the problem in the code and in update_div $this-
Mymodel-validate seems to have the correct value but I put a log
line in beforeValidate() (in the model) and the validate property is
not equal to myrules but it has the default rules value. :-(

I don't understand if it is wrong to change the validation rules in my
function (started by ajax) and what method or function changes the
validate property after it is set in my update_div() function.

Any suggestion?

Thanks
maxx

--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: MultivalidatableBehavior problem

2009-10-09 Thread emmexx



On 9 Ott, 18:35, Dr. Loboto drlob...@gmail.com wrote:
 Check for correct rules key.

I don't think the problem is with the rules key.
As I wrote in my post if I log $this-validate after setting myrules,
that is:
$this-Mymodel-setValidation('myrules');
$this-log($this-validate);
I find the correct rules in error.log.
But if I check the value of $this-validate in beforeValidate() the
value is the default rule.

So I suppose that  $this-validate is reset (by whom)? in between
update_div() and beforeValidate().
Or $this-Mymodel-setValidation('myrules') sets the wrong validate
variable.

Thank you
   maxx




--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Notice+error after file upload

2009-10-08 Thread emmexx



On 8 Ott, 08:01, Bert Van den Brande cyr...@gmail.com wrote:
 Setting debug to 0 will work around your problem since PHP notices won't be
 shown then.

I presumed that... :-)
My question was about the different behaviour on my laptop and on my
web host.
The debug level is the same: 2.
On my pc the notice is only present in the debug.log.


 Of course, the real root of the problem is the fact that the uploader tries
 to access an array with a var that doesn't exist. Have a look at the script
 on line 695 and try to figure out why it's not set.

 Possibly it's a small bug, then you should contact Miles :)

Or Miles should contact me! ;-)

Thank you
maxx
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Translate field names

2009-10-08 Thread emmexx

Thank you Brian for the explanation.

   maxx



--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Notice+error after file upload

2009-10-07 Thread emmexx

I use Miles Johnson's Uploader plugin in a model.
http://www.milesj.me/resources/script/uploader-plugin

On my pc I have no problem.
On the host where I'm testing my application after saving a record a
receive the following messages.
The page seems partially broken, it is not the index page, but I
verified that the file has been uploaded and the record saved.

How can I remove this message?

thank you
maxx

Notice (8): Undefined index:  group [APP/plugins/uploader/controllers/
components/uploader.php, line 695]

Code | Context

$this   =   uploadercomponent
uploadercomponent::$_log = NULL
uploadercomponent::$version = 2.1
uploadercomponent::$data = array
uploadercomponent::$logs = array
uploadercomponent::$current = filename
uploadercomponent::$enableUpload = true
uploadercomponent::$maxFileSize = 5M
uploadercomponent::$maxNameLength = 40
uploadercomponent::$scanFile = false
uploadercomponent::$tempDir = /a_path/cake2/app/tmp/
uploadercomponent::$uploadDir = files/uploads/
uploadercomponent::$mimeTypes = array
uploadercomponent::$enabled = true
uploadercomponent::$Controller = resourcescontroller object
uploadercomponent::$Folder = folder object
uploadercomponent::$finalDir = /a_path/cake2/app/webroot/files/
uploads/
$file   =   filename
$options=   array(
name = null,
overwrite = false,
multiple = false
)
$defaults   =   array(
name = null,
overwrite = false,
multiple = false
)

upload - [internal], line ??
uploadercomponent::upload() - APP/plugins/uploader/controllers/
components/uploader.php, line 695
resourcescontroller::add() - APP/controllers/resources_controller.php,
line 26
resourcescontroller::dispatchmethod() - CORE/cake/libs/object.php,
line 115
dispatcher::_invoke() - CORE/cake/dispatcher.php, line 227
dispatcher::dispatch() - CORE/cake/dispatcher.php, line 194
[main] - APP/webroot/index.php, line 88

Warning (2): Cannot modify header information - headers already sent
by (output started at /a_path/cake2/cake/basics.php:111) [CORE/cake/
libs/controller/controller.php, line 640]

--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: image path in javascript file

2009-10-06 Thread emmexx



On 6 Ott, 06:20, Dr. Loboto drlob...@gmail.com wrote:
 $options = $javascript-object(array ('IMAGE_BASE' = $html-url('/js/
 colorpickerjs/img/')));

As Einstein said, everything should be made as simple as possible, but
not simpler.

Thank you
maxx
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Translate field names

2009-10-06 Thread emmexx

On 25 Set, 12:47, rich...@home richardath...@gmail.com wrote:
 No, you only want to translate the label, not the field name :

 echo $form-input(field_name, array(label=__(field_name)));

I tried what you suggested but the result is not what I espected.

1st attempt:

echo $form-input('table_id', array('label' = __('table_id')));

The output is:
table_id
Table
that is a label and the name of the joined table.
Unfortunately I want just one label, Table, translated if there's a
translation.

2nd attempt:
echo $form-input('table_id', array('label' = __('table_id', True)));

The output is:
table_id
I expected: Table

I'm missing something? I'm expecting too much from cake?

Thank you
   maxx
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Translate field names

2009-10-06 Thread emmexx



On 6 Ott, 19:54, brian bally.z...@gmail.com wrote:
 Do you have a .po file containing a translation for 'table_id'? And
 have you set the language?

Not yet but I expected that without a po file, or a translation, the
label defaulted to the value used automatically by cake.
I mean, if there's a belongTo field in the table, say category_id, I
expected that the result of
echo $form-input('category_id', array('label' = __('category_id',
True)));
would be Category, not category_id. That is: no translation 
default value.
I don't expect cakephp doing all the programming work for me, just
trying to understand what cake can do for me.

Thank you
   maxx

--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



image path in javascript file

2009-10-05 Thread emmexx

I'm trying to use colorpickerjs in cakephp but I have some trouble
with the image files used by this tool.

http://code.google.com/p/colorpickerjs/

The javascript file of the tool references all images with the
following code:

this.options = Object.extend({
   IMAGE_BASE : img/
}, options || {});

and then:
element.innerHTML='div id=colorpicker-selectorimg src=' +
this.options.IMAGE_BASE + 'select.gif width=11 height=11 alt= /
/div';

That code translates in the following html inside my cake application:

div id=colorpicker-hue-thumb class=selected style=top: 92px;
img src=img/hline.png/
/div

(just look at the img tag)

And of course the image cannot be found...

Is there a cakephp way to solve this? I mean, I can't use a
htmlHelper, I suppose I should modify the IMAGE_BASE path or put the
colorpickerjs files elsewhere (now they are inside webroot/js/
colororpickerjs).
I'd prefer non to modify the javascript code.

Thank you
   maxx
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: image path in javascript file

2009-10-05 Thread emmexx


On 5 Ott, 19:12, vekija vedran.konto...@gmail.com wrote:
 when you call colorpicker function, add options hash as a second
 parameter {IMAGE_BASE: 'img/'}. Change the path to one where your
 images are, but if you store them in your app's image folder it should
 most likely be /img/.

Thank you for the tip.
I had to write the following:
$pos = strpos(env('PHP_SELF'), /,1);
if ($pos === false) {
$this-log(errore in path);
$pickpath=;
} else {
$pickpath=substr(env('PHP_SELF'),0,$pos);
}
$optionsi='{IMAGE_BASE:'.$pickpath.'/js/colorpickerjs/img/}';
echo $javascript-codeBlock(new Control.ColorPicker
('ParameterKeyColor',$options));

The 1st part is needed to retrieve the installation folder of cake, I
couldn't find a cake constant for that.

Bye
   maxx

--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



HABTM and multiple level

2009-09-29 Thread emmexx

I need to tag some record, say picture, with a tree-like model.

I have a pictures model and a category model.

The category model has 3 fields connected as a tree:

cat1
cat2
cat3

The tree structure could be:

art
   painting
  minimalism
  expressionism
  ...
   sculpture
nature
   trees
   flowers
  roses
  ...

When I enter a new picture I'd like to be able to select many tags
from category, say, art-painting-expressionism and nature-trees.
And I'd like to be able to select each category tag using cascading
select boxes.

Is there a natural way to bake this in cakephp?

Thank you
   maxx
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Translate field names

2009-09-28 Thread emmexx



On 25 Set, 12:47, rich...@home richardath...@gmail.com wrote:
 No, you only want to translate the label, not the field name :

 echo $form-input(field_name, array(label=__(field_name)));

Ok, thank you, not a recipe as simple as I imagined but easy enough to
do it by hand.

bye
   maxx
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Translate field names

2009-09-25 Thread emmexx



On 25 Set, 02:18, brian bally.z...@gmail.com wrote:
 __('field_name')


Do you mean that I can use in a view something like the following?

echo $form-input(__('date'));

Thanks
   maxx

--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Show or hide fields on select change

2009-09-23 Thread emmexx

I'm working on a view to add a record to a table.
The table (or model) has a field and this field belongsTo another
model.
In the second model there's another field and, depending on the value
of this field, I want to show or hide some element in the
aforementioned view.

E.g.:
table1  model1
id
name
table2_id
optional_field1
optional_field2

table2  model2
id
flag

When I'm in the add view of model1 and I select a value for
table2_id I want to query table2, check the value of flag and show or
hide optional_field1 and optional_field2 if flag is true or false.

I tried to solve this in 2 ways but none works.
1st method:
In the add view of Model1 I put:
$options = array('url' = 'update_div','update' =
'someid');
echo $ajax-observeField('model1table2id',$options);

In the view I don't put
$form-input('optional_field1');
$form-input('optional_field2');

In the controller I put an update_div action that checks model2-flag
and I created a view update_div that echoes
$form-input('optional_field1');
$form-input('optional_field2');

This approch works, sort of but, when I save, optional_field1 and
optional_field2 aren't saved, the format of the array $this-data in
the controller is wrong for the optional fields. :-(

2nd method:
In the add view
$remoteFunction = $ajax-remoteFunction(
array(
'url' = 'update_div',
'with' = 
'Form.Element.serialize(model1table2id)'
)
);
echo $form-input('table2_id', array('onchange' =
$remoteFunction));

In the view I put
$form-input('optional_field1');
$form-input('optional_field2');

The controller action update_div is the same as in the 1st example.
In the update_div.ctp file I tried to put some javascript to hide or
show the div that contains the optional fields but the script isn't
executed.

Can you please help me and suggest me the right way to accomplish
this?

Thank you
   maxx
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Parametric model?

2009-09-07 Thread emmexx

The object is probably wrong but I couldn't find anything better.

I want to bake an application that let's some users select which
fields should be shown (for some selected table).
I have a model, say Master, and each main record has an associated
Detail model (hasMany - BelongsTo relationship).

Some supervisor user should be able to select, say, Details.field1,
Details.field3, and so on and other users should see only this fields
when viewing/adding/editing Detail record.

Is there a way to do this easily in cakphp?

Thank you

   maxx

--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Nested data saving

2009-05-21 Thread emmexx

I'd like to accomplish the following:

I have a Mains table and a Files table
The Main table contains various information.
The Files table records info about one or more files connected to the
Main table (through a foreignkey field).

When I create a new Main record I need to fill in info about the file
(I need to upload a file and make some operation about it). For
example the file could be a gpx or kml file and I want to retrieve
info that are into that file, upload the file, save the path in Files
and save the gpx info in the main table.

I tried to put a link to the 'add' view of Files in the 'add' view of
Mains but after Saving the file record I don't know how to go back to
mains.add without losing data entered in the fields.

I want to know if there's a cake method to to this or if I have to
code everything from scratch.
Note that I don't want to save the main record before having saved the
file record.

Thank you
  maxx
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: belongsTo conditions in model

2009-05-15 Thread emmexx

On 15 Mag, 00:10, emmexx emmeics...@gmail.com wrote:

(cut)
 I created a model for segment with a belongsTo variable:

         var $belongsTo = array(
                 'Car' = array(
                         'className' = 'Parameter',
                         'foreignKey' = 'par1_id',
                         'conditions' = array('Car.type_id' = 55)
(cut)

 I don't understand if I'm missing something or doing something wrong
 or I'm asking too much to cakephp.

I checked the code in cake/libs/model/model.php and the find function,
as I understand, doesn't care about $this-belongsTo.
Therefore I don't understand where and when the model association gets
used.
The manual in the chapter about Association (http://book.cakephp.org/
view/78/Associations-Linking-Models-Together) says:

Once this association has been defined, find operations on the User
model will also fetch a related Profile record if it exists: (...)

   maxx

--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



belongsTo conditions in model

2009-05-14 Thread emmexx

Hi everybody,

I started using cakephp yesterday and I find it very smart.

I have a problem trying to filter the results of a table used in a
model.

I have 2 tables, segments and parameters.

Parameters is defined as the following:
id
name
type_id

Segments id defined as the following:
id
name
par1_id
par2_id
par3_id

par1, par2 and par3 should be aliases of the parameters table filtered
by parameters.type_id.
E.g.
parameters:
1   Toyota   55   (55 is the type and means cars)
2   Banana  34  (34 means fruits)
3   hammer 23   (23 means tools)

When adding a new segment record par1 should list only cars, par2 only
fruits and par3 only tools.

I created a model for segment with a belongsTo variable:

var $belongsTo = array(
'Car' = array(
'className' = 'Parameter',
'foreignKey' = 'par1_id',
'conditions' = array('Car.type_id' = 55)
),
'Fruit' = array(
'className' = 'Parameter',
'foreignKey' = 'par2_id',
'conditions' = array('Fruit.type_id' = 34)
),
'Tool' = array(
'className' = 'Parameter',
'foreignKey' = 'par3_id',
'conditions' = array('Tool.type_id' = 23)
));

but the fields are not filtered.

In the query list section there are the 3 queries but there's no where
condition (something like .. INNER JOIN Parameters as Car WHERE
car.type_id=55) and no joins or aliases.
If I list segments In the query list section there are joins and
alaises yet. :-(

I don't understand if I'm missing something or doing something wrong
or I'm asking too much to cakephp.

Thank you for any suggestion

maxx

--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---