hasMany problems/bug - need feedback

2010-08-27 Thread Dan Heberden
This isn't a i cant get this or that model or relationship question,
btw :)

(this is cake 1.3.2 an i've shortened the selects for readability
sake)

Consider these models/relationships:  User, Group, Post

User belongsTo Group
User hasMany   Post

With recursive set to 1, you'd think that the select would join users
to the group AND the posts. NOT the case.

Here's an example of what cake is generating:
 SELECT * FROM `users` AS `User`
LEFT JOIN `groups` AS `Group` ON (`User`.`group_id` =
`Group`.`id`)

so it has a crap load of student rows. Then it creates this:

  SELECT * FROM `posts` as `Post`
  WHERE `Post`.`user_id` IN ( 1, 2, 3, 4 , 5)

So basically it is looping through the first record set, building the
IN query and getting them manually.

It SHOULD be doing this:

SELECT * FROM `users` AS `User`
LEFT JOIN `groups` AS `Group` ON (`User`.`group_id` =
`Group`.`id`)
LEFT JOIN `posts` AS `Post`
  ON (`Post`.`user_id` = `Student`.`id` AND
`Post`.`status`  2
AND `Post`.`status` = 0)

Not only for network traffic and multiple sql calls, but speed. The
first call takes 140ms with the data I have. The joined one takes
74ms.

This gets even worse with containable. Instead of joining the group,
it SELECTS every group by id for every user. It's generating like 70
queries instead of one join.

I want to make sure i'm not missing something before I post this as a
bug. Have any of you noticed this?

I have tried to see if different levels of recursion affect the
generated sql, but, as you'd expect it does what it's supposed to to
in traversing levels up or down.


Another example, If I add a Comment model to the mix (Post hasMany
Comments) and do this:
$this-contain( array( 'Group', 'Post' = array('Course') ));

The first generated SQL is the join of the users to groups as before,
but then is ALSO generates individual lines of SQL to get each group
(again).

So it makes this: SELECT * FROM `users` AS `User`
LEFT JOIN `groups` AS `Group` ON (`User`.`group_id` =
`Group`.`id`)

Then these:
 SELET * FROM `groups` as `Group` WHERE `Group`.`id` = 1;
  SELET * FROM `groups` as `Group` WHERE `Group`.`id` = 2;
SELET * FROM `groups` as `Group` WHERE `Group`.`id` = 3;
  SELET * FROM `groups` as `Group` WHERE `Group`.`id` = 4;

It gets the Posts as before, but then generates individual SQL calls
for EACH comment.

Messed up, right?




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: after adding an hasOne relation to model it is not available in my view anymore

2010-08-20 Thread Dan Heberden
Is debugging on so you can see the sql error? It's having trouble
'finding one' - which is one generative sql call so if IT fails the
whole bloody thing fails and you get an empty array.


On Aug 19, 2:55 pm, Marcos  Mendonça marc...@gmail.com wrote:
 have you tried without the 'dependent' = true attribute?

 On Aug 19, 3:58 pm, Tomfox Wiranata tomfox.wiran...@gmail.com wrote:



  hi,

  weird thing. i declare a hasOne relation:

  class User extends AppModel
  {
      var $name = 'User';

      var $hasOne = array(
                  'Link' = array(
                          'className' = 'Link',
                          'dependent' = true
                  )
          );

  }

  suddenly i am having undefined index everywhere i use that model in
  my views, like:

  span class=profiledata?php echo $user['firstname']; ?/span

  if i delete the hasOne part it works fine and the view shows the user
  data...what the heck did i do wrong? looking forward to your
  feedback..

  big big thx

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: problema com imagens captcha

2010-08-19 Thread Dan Heberden
Is debug set to 0? chances are your application is already sending
data and the captcha can't change the header back to image/jpeg..

Configure::write('debug', 0);



On Aug 19, 1:52 pm, Juliano Bordignon bordigno...@gmail.com wrote:
 hello

 did not work .. I did that but still showing the codes ..

 is very strange, because I have the same function in another system
 and works fine.

 thanks dude

 On 19 ago, 17:40, Andras Kende and...@kende.com wrote:



  In that function try to disable the layout :

  $this-autoLayout = false;

  Andras Kendehttp://www.kende.com

  On Aug 19, 2010, at 4:03 PM, Juliano Bordignon wrote:

   Hello everyone

   I have a strange problem that I got an application for support ..

   I need to put a captcha system, already tested the phpcaptcha and
   securimage ..

   both when the controller calls the function that displays the image,
   show the captcha as if I send a picture to open the notepad .. a lot
   of code ¬ ¬

   anyone has any idea what this is .. thanks

   Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp 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 
   athttp://groups.google.com/group/cake-php?hl=en

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

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


Re: Countries, States and Cities: Which relations i'm dealing with?

2010-08-06 Thread Dan Heberden
you might want to peek into the tree behavior - it makes multi-level
stuff much easier (haven't used the behavior personally, but have used
MPTT quite a bit)

As for your models:

You mentioned your states and countries have the city foreign key,
which I assume is stricly for their capital. This is a belongsTo; when
the key is present in the CURRENT table..

state:
$belongsTo( 'CapitalCity' =  array( 'className' = 'City'),
   'Country' ); // city_id on state maps to the
capital, country_id maps to the country
$hasMany('City'); // state_id on the cities table map to the current
state (gets all the cities)

country:
$belongsTo('City') // city_id on country maps to capital (gets the
capital city)
$hasMany( 'State') // country_id on the states table maps to the
current country (gets all the states);
(note, if you need the whole chain, you can use containable - it would
let you specify the link such as:
$this-contain('City', 'State' = 'CapitalCity', 'City') // this gets
the countries capital city, states and that states capital and
cities.. cool, eh? )

city:
$belongsTo = array('State') // city has state_id, which gets it's
parent state
( again, you can use containable to get further into state, like get
the state's country and ITs capital, etc etc)

The use of containable is much more flexible than recursive, as it
lets you specify the relationships. 
http://book.cakephp.org/view/1323/Containable
)

hope it helps,
dan


On Aug 5, 8:43 am, DerBjörn b.unkh...@googlemail.com wrote:
 Hi,

 i have three tables: countries, states and cities.

 Every country has its capital city, so does every state.
 2 relations are very obvious:

 state belongsTo country
 city belongs to state

 Now i have a problem to realize the relations referring to the capital
 cities.
 In my opinion there are two hasOne relations:

 state hasOne city
 country hasOne city

 Both tables (states and countries) has a column names city_id as
 foreign_key, but if i use two hasOnes like

 [code]
 var $hasOne = array(
         'CapitalCity' = array(
             'className' = 'City',
             'foreignKey' = 'city_id',
             'conditions' = '',
             'fields' = '',
             'order' = ''
         )
     );
 [/code]

 i get following error message:
 [quote]Warning (512): SQL Error: 1054: Unknown column
 'CapitalCity.capitalcity_id' in 'on clause' [CORE/cake/libs/model/
 datasources/dbo_source.php, line 681][/quote]

 [quote]Query: SELECT COUNT(*) AS `count` FROM `countries` AS `Country`
 LEFT JOIN `cities` AS `CapitalCity` ON (`CapitalCity`.`city_id` =
 `Country`.`id`) WHERE 1 = 1 [/quote]

 Actually it has to be  (`CapitalCity`.`id` = `Country`.`city_id`) to
 make sense. What i did wrong?
 In a forum i asked i ve been told that to realize the capital city
 connections i have to use 2 belongsTo relations, but it doesn't make
 any sense to me.

 Somebody can enlight me? :)
 Thanks!

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

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


Re: bug with HTML entity encoding of attribute of form elements

2010-08-06 Thread Dan Heberden
As for the quotes thing - i meant sending the slash along with it, so
the rendered, parse, printed, whatever text would _look_ like

onclick=function(\xxx\);   more or less a work around

I agree that it needs to be something specific.. I think escape needs
to be mixed - that way it would be backwards compatible..

echo $this-Form-button('button', array('onClick' =
'function(\'xxx
\')', 'escape' = true));

would still work OR

echo $this-Form-button('button', array('onClick' =
'function(\'xxx
\')', 'escape' = array('name') ));

To specify WHAT gets escaped.  - if array, defaults to false for all
others.

Kind of like containable does..




On Aug 6, 4:28 am, drbuzasi drbuz...@gmail.com wrote:
 Of course i mean at my first question: ...different options for title/
 selectoptions and for attributes in future versions...

 On aug. 6, 13:21, drbuzasi drbuz...@gmail.com wrote:



  I think that's not a problem of php escaping. Using double quotes in
  javascript isn't a good idea since the code generated (assuming it
  won't be escaped) would be
  ... onChange=functon(yyy)...
  which is meanless because of the wrapping double quotes.

  IMHO the problem is in form.php and helper.php.

  Button problem:
  If 'escape' is set true as option in form.php (CakePHP 1.3.3) line
  1266 makes title escaped. After then the option remains causing
  attributes getting escaped as well calling _parseAttributes at line
  1271.
  So title AND attributes will be encoded if 'escape'=true but none of
  them while set ti false.

  Select (and $form-input generally) problem:
  Setting 'escape'=true HTML encodes only select options because line
  1426 saves the value for line 1498 but line 1427 unsets this option.
  So when calling _parseAttribute at line 1475 this option is not
  present causing use of default value at line 336 in helper.php.
  Select attributes will be ALWAYS encoded.

  Question:
  Should be used different escape options for title/selectoptions in
  future versions of CakePHP? Or the default value in helper.php line
  336 should be set tu false?

  On aug. 6, 06:35, Dan Heberden danheber...@gmail.com wrote:

   Does changing your quote pattern help?

   echo $this-Form-select('field', array( '1' = 'one' , '2' =
   'two' ),
                                             null, array('onChange' =
   'function(\yyy\)'));

   \ (because php isn't escaping it) will get sent to the output, which
   _should_ render

   onclick=function(\yyy\) -

   I would do some more tests with sending double quotes vs single quotes
   for the ent_quote option of the $form helper..

   On Aug 5, 5:27 pm, drbuzasi drbuz...@gmail.com wrote:

If a button is needed that is labeled as 'button' and has an
'onClick' attribute with some javascript containing a text parameter
the code can't be created since when 'escape' is set to false in
options (button default) the script is OK but buttons label will not
be encoded.
Setting 'escape' to true HTML encodes my script, too, which is wrong.

echo $this-Form-button('button', array('onClick = 'function(\'xxx
\')'));
results
button type=submit onClick=function('xxx')button/button

echo $this-Form-button('button', array('onClick' = 'function(\'xxx
\')', 'escape' = true));
results
button type=submit
onClick=function(#039;xxx#039;)lt;buttongt;/button

echo $this-Form-button('button', array('onClick' = 'function(\'xxx
\')', 'escape' = false));
results
button type=submit onClick=function('xxx')button/button

A similar problem is to create a select field with an 'onChange'
attribute containing the same javascript as above. By this default of
'escape'
attribute is set true which is of course desirable to have the select
options HTML encoded. But irrespectively of this attribute the script
will
ALWAYS be encoded as shown below so that makes it uninterpretable.

echo $this-Form-select('field', array('1'='one', '2'='two'),
null, array('onChange' = 'function(\'yyy\')'));
select name=data[field] onChange=function(#039;yyy#039;)
id=field
option value=/option
option value=1lt;onegt;/option
option value=2lt;twogt;/option
/select

echo $this-Form-select('field', array('1'='one', '2'='two'),
null, array('onChange' = 'function(\'yyy\')', 'escape' = true));
select name=data[field] onChange=function(#039;yyy#039;)
id=field
option value=/option
option value=1lt;onegt;/option
option value=2lt;twogt;/option
/select

echo $this-Form-select('field', array('1'='one', '2'='two'),
null, array('onChange' = 'function(\'yyy\')', 'escape' = false));
select name=data[field] onChange=function(#039;yyy#039;)
id=field
option value=/option
option value=1one/option
option value=2two/option
/select

Any idea how to correct it? Should a ticket be created according to
this problem?

Check out the new CakePHP Questions site http

Re: How to allow and deny different actions based on user's role

2010-08-06 Thread Dan Heberden
Just get the role and apply it?

if( $this-Auth-user('User.role')  1 )  {   // is admin
   $this-Auth-allow( array('secretController' =
'superSecureAction' ) );
}

On Aug 6, 1:12 pm, Mariano C. mariano.calan...@gmail.com wrote:
 I have users table, with field id, username, password and role.
 role is a numeric value: 0 banned users, 1 registered users, 2 admins.

 I've coded AppController like:
 class AppController extends Controller {
         var $components = array('Auth');

         function beforeFilter()
         {
                 $this-Auth-allow(array('users' = 'register'));
         }

 }

 So every user can reach registration page.
 Now I would that for user with different role will be allowed
 different action. How can I handle this just inside the AppController?

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: some phone validation rule problem

2010-08-05 Thread Dan Heberden
This was answered via email, but aparently google didn't get it in the
group so:

If the table is set to a numeric field (tinyint, smallint, int,
bigint) it will parse out the leading zero - the best would be a
varchar for how many characters you need. e.g. if you're storing your
numbers as 09+124-345-7890 then you want a varchar(15).

If you are storing completely numeric values and need leading zeros in
all cases, use sprintf:

$number = 91234567890;
$number = sprintf( %12d, $number); // 091234567890

$number = 191234567890; (already 12 digits long)
$number = sprintf( %12d, $number); // 191234567890

On Aug 4, 7:51 am, hoss7 hoss...@gmail.com wrote:
 @dan thank you,but i have little problem,when i want save '09' in
 table i dont have
 '09' i have '9'

 if i want user phone number dont start with 09 what i am must to do?

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: bug with HTML entity encoding of attribute of form elements

2010-08-05 Thread Dan Heberden
Does changing your quote pattern help?

echo $this-Form-select('field', array( '1' = 'one' , '2' =
'two' ),
  null, array('onChange' =
'function(\yyy\)'));

\ (because php isn't escaping it) will get sent to the output, which
_should_ render

onclick=function(\yyy\) -

I would do some more tests with sending double quotes vs single quotes
for the ent_quote option of the $form helper..



On Aug 5, 5:27 pm, drbuzasi drbuz...@gmail.com wrote:
 If a button is needed that is labeled as 'button' and has an
 'onClick' attribute with some javascript containing a text parameter
 the code can't be created since when 'escape' is set to false in
 options (button default) the script is OK but buttons label will not
 be encoded.
 Setting 'escape' to true HTML encodes my script, too, which is wrong.

 echo $this-Form-button('button', array('onClick = 'function(\'xxx
 \')'));
 results
 button type=submit onClick=function('xxx')button/button

 echo $this-Form-button('button', array('onClick' = 'function(\'xxx
 \')', 'escape' = true));
 results
 button type=submit
 onClick=function(#039;xxx#039;)lt;buttongt;/button

 echo $this-Form-button('button', array('onClick' = 'function(\'xxx
 \')', 'escape' = false));
 results
 button type=submit onClick=function('xxx')button/button

 A similar problem is to create a select field with an 'onChange'
 attribute containing the same javascript as above. By this default of
 'escape'
 attribute is set true which is of course desirable to have the select
 options HTML encoded. But irrespectively of this attribute the script
 will
 ALWAYS be encoded as shown below so that makes it uninterpretable.

 echo $this-Form-select('field', array('1'='one', '2'='two'),
 null, array('onChange' = 'function(\'yyy\')'));
 select name=data[field] onChange=function(#039;yyy#039;)
 id=field
 option value=/option
 option value=1lt;onegt;/option
 option value=2lt;twogt;/option
 /select

 echo $this-Form-select('field', array('1'='one', '2'='two'),
 null, array('onChange' = 'function(\'yyy\')', 'escape' = true));
 select name=data[field] onChange=function(#039;yyy#039;)
 id=field
 option value=/option
 option value=1lt;onegt;/option
 option value=2lt;twogt;/option
 /select

 echo $this-Form-select('field', array('1'='one', '2'='two'),
 null, array('onChange' = 'function(\'yyy\')', 'escape' = false));
 select name=data[field] onChange=function(#039;yyy#039;)
 id=field
 option value=/option
 option value=1one/option
 option value=2two/option
 /select

 Any idea how to correct it? Should a ticket be created according to
 this problem?

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

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


Re: Autocomplete, can't find $this-data?

2010-08-04 Thread Dan Heberden
One note (for future readers too) - you are forcing your form element
to GET - only POST data is populated into $this-data.

On Aug 3, 8:11 pm, Louie Miranda lmira...@gmail.com wrote:
 *Solved it!*

 I can't seem to debug($this-data), so I debug($this-params);

 And found the solution.

 $this-params['form']['q'];

 Instead of

 $this-data['q']

 Which is not working.

 Regards,
 --
 Louie Miranda
  - Email: lmira...@gmail.com
  - Web:http://www.louiemiranda.com

 On Wed, Aug 4, 2010 at 11:04 AM, Louie Miranda lmira...@gmail.com wrote:
  I tried the ajax autocomplete manual.
 http://book.cakephp.org/it/view/1370/autoComplete

  *PROBLEM:*

     1. I can't seem to query $this-data['q'];
     2. Therefore, the auto complete list shows, everything. And not the
     specific keyword or q value.

  How will I query $this-data['q'];? I think, I followed everything. What
  seems to be wrong?

  The codes:

  *Added my controller*

  function autocompletetitle() {
      $this-set('results', $this-Publication-find('all', array(
              'conditions' = array(
                  'Publication.itemName LIKE' = $this-data['q'].'%'
                  ),
              'fields' = array('itemName')
                  )));
      $this-layout = 'ajax';
  }

  *And my form*

  ?php echo $form-create('Publication', array('action' = 'sresults',
  'type' = 'get'));?
  ?php echo $ajax-autoComplete('q', '/publications/autocompletetitle'); ?
  ?php echo $form-end('Search'); ?

  The autocompletetitle view is set and working, I can see it when accessing
  /autocompletetitle and if I search.

  --
  Louie Miranda
   - Email: lmira...@gmail.com
   - Web:http://www.louiemiranda.com

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

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


Re: how can I check if form button is pressed?

2010-08-04 Thread Dan Heberden
Since you're creating your form with model 'ABC', your data array
should look like

$this-data['ABC'][]

So instead of checking for the presence of data in it's entirety,
check for that specific key:

if( !empty( $this-data['ABC'] ) ) {
   // execute saving method
}

If you were sending data along too, such as

echo $form-hidden('id'); // still assuming the ABC model

Then you could check for

if( !empty( $this-data['ABC']['id'] ) ) {
   // run operation
}

-dan


On Aug 4, 6:36 am, Tomfox Wiranata tomfox.wiran...@gmail.com wrote:
 i did react on form submitting a bunch of timesbut it seems
 different since there is no input field...

 do i need to place just a button without a form? seems to make sense.
 dont know if that is possible!!?

 On 4 Aug., 15:19, Tomfox Wiranata tomfox.wiran...@gmail.com wrote:



  hi everyone,

  this seems really easy, but it's giving me a headache. I have a
  function in my controller:

  function createABC() {

  // save stuff in database

  }

  this function is triggered by a form in a view, named createABC.ctp.
  like this

  echo $form-create('ABC', array('action' = 'createABC'));
  echo $form-button('save', array('type' = 'submit'));
  echo $form-end();

  now, I do not want to start the saving procedure everytime the view is
  called. so i wanna check if this button is hit first. if it is, then
  save all the data. so i tried to check it like that:

  function createABC() {

     if (!empty ($this-data)) {
        // save stuff in database
     }

  }

  it does not work. anybody know why?

  huuuge thx

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: some phone validation rule problem

2010-08-04 Thread Dan Heberden
regex might be a better route:

'mobile' = array(
'rule' = '/^09/',
'message' = 'no
)


On Aug 4, 6:06 am, hoss7 hoss...@gmail.com wrote:
 if i want user phone number dont start with 09 what i am must to do?

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 check if form button is pressed?

2010-08-04 Thread Dan Heberden
Can you post the whole output of:

pr( $this-data );
pr( $this-params['form'] );

for me?


On Aug 4, 7:35 am, Tomfox Wiranata tomfox.wiran...@gmail.com wrote:
 thx dan. unfortunately it does not work yet.

 in my function i did

 print_r($this-data['Linkable'];

 to see whats in the array. since there is no output at all, i assume
 the array is empty. that explains the no reaction on if !empty,
 right?

 i also tried adding a hidden field

 echo $form-hidden('test');

 and wrote in my function:

 if( !empty( $this-data['ABC']['test'] ) ) {

 to make sure  a value is given for sure

 still nothingany idea?

 thx

 On 4 Aug., 16:20, Dan Heberden danheber...@gmail.com wrote:



  Since you're creating your form with model 'ABC', your data array
  should look like

  $this-data['ABC'][]

  So instead of checking for the presence of data in it's entirety,
  check for that specific key:

  if( !empty( $this-data['ABC'] ) ) {
     // execute saving method

  }

  If you were sending data along too, such as

  echo $form-hidden('id'); // still assuming the ABC model

  Then you could check for

  if( !empty( $this-data['ABC']['id'] ) ) {
     // run operation

  }

  -dan

  On Aug 4, 6:36 am, Tomfox Wiranata tomfox.wiran...@gmail.com wrote:

   i did react on form submitting a bunch of timesbut it seems
   different since there is no input field...

   do i need to place just a button without a form? seems to make sense.
   dont know if that is possible!!?

   On 4 Aug., 15:19, Tomfox Wiranata tomfox.wiran...@gmail.com wrote:

hi everyone,

this seems really easy, but it's giving me a headache. I have a
function in my controller:

function createABC() {

// save stuff in database

}

this function is triggered by a form in a view, named createABC.ctp.
like this

echo $form-create('ABC', array('action' = 'createABC'));
echo $form-button('save', array('type' = 'submit'));
echo $form-end();

now, I do not want to start the saving procedure everytime the view is
called. so i wanna check if this button is hit first. if it is, then
save all the data. so i tried to check it like that:

function createABC() {

   if (!empty ($this-data)) {
      // save stuff in database
   }

}

it does not work. anybody know why?

huuuge thx

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