Re: Cake 3 - Modelless Forms with nested forms / elements

2015-06-02 Thread slowjack2k
Hi Karthik,

I don't know how your answer should solve my problem. Maybe I didn't 
explain it enoug.
I would like to have a Form, where I can fill in multiple Phonenumbers and 
I don't know bevor hand
how many phone numbers there will be. After receiving the data from the 
user I want to validate
the phonenumber,

regards
Dieter


Am Montag, 1. Juni 2015 16:04:02 UTC+2 schrieb Karthik Keyan:
>
>
>
> Hi, Create the form name in /src/UserForm1.php
> namespace App\Form;
>
> use Cake\Form\Form;
> use Cake\Validation\Validator;
>
> class UserForm1 extends Form {
>
> protected function _buildValidator(Validator $validator) {
> return $validator
> ->notEmpty('annul_income', 'please enter the 
> Annual income')
> ->add('annul_income', 'annul_income number should 
> be numeric', ['rule' => 'numeric'])
>
> ->notEmpty('terms', 'You must accept our terms of 
> service')
> ->add('terms', [
> 'equalTo' => [
> 'rule' => ['equalTo', '1'],
> 'message' => 'You must accept our terms of 
> service'
> ]
> ]);
> }
>
> public function setErrors($errors) {
> $this->_errors = $errors;
> }
>
> }
> In Controller File:
> -
> $rate = new UserForm1();
>  
>   $this->set(compact('rate'));
> Don't forgot to add use App\Form\UserForm1;
> Top of the controller
>
>
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: Cake 3 - Modelless Forms with nested forms / elements

2015-06-01 Thread Karthik Keyan


Hi, Create the form name in /src/UserForm1.php
namespace App\Form;

use Cake\Form\Form;
use Cake\Validation\Validator;

class UserForm1 extends Form {

protected function _buildValidator(Validator $validator) {
return $validator
->notEmpty('annul_income', 'please enter the Annual 
income')
->add('annul_income', 'annul_income number should 
be numeric', ['rule' => 'numeric'])

->notEmpty('terms', 'You must accept our terms of 
service')
->add('terms', [
'equalTo' => [
'rule' => ['equalTo', '1'],
'message' => 'You must accept our terms of 
service'
]
]);
}

public function setErrors($errors) {
$this->_errors = $errors;
}

}
In Controller File:
-
$rate = new UserForm1();
 
  $this->set(compact('rate'));
Don't forgot to add use App\Form\UserForm1;
Top of the controller


-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Cake 3 - Modelless Forms with nested forms / elements

2015-05-31 Thread slowjack2k
Hi,

within the documenation I did only find a simple example 
(http://book.cakephp.org/3.0/en/core-libraries/form.html).
Is it possible to create a form with "Sub-Forms"?


class PhoneNumberForm extends Form
end

class ContactForm extends Form{

protected function _buildSchema(Schema $schema)
{
return $schema->addField('name', 'string')
->addField('email', ['type' => 'string'])
->addField('body', ['type' => 'text']);
->addField('phonenumbers', ['type' => ? ]); } // should be an 
array of PhoneNumberForms
}


regards
dieter


-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


mathematical operations with forms in cakephp

2015-01-12 Thread Jorge I Pineda G
Buenas tardes, ante todo un cordial saludos para todos en el foro.
tengo un inconveniente, y necesito ayuda.
por favor serian tan amables de ayudarme con información , textos, 
ejemplos, para realizar operaciones matematicas en cakephp, el problema es 
que aun soy muy novato y se me complica un poco todo este tema, para tener 
una idea mejor esta es mi vista :

English:
Good afternoon, first of all a cordial greetings to all forum.
I have a problem and need help.
please would be so kind to help me with information, text, illustrations, 
to perform mathematical operations in cakephp, the problem is that I am 
still a newbie and I was a bit complicated this whole issue, to get a 
better idea this is my view:




Lo que yo quiero es ir poniendo las cantidades y luego hacer la operación 
con respecto al precio hacer un solo calculo y colocarlo en el total, 
por ejemplo en cantidad_adulto ingresar 2 y por detras multiplicarlo con el 
7.50 que es el valor y asi con todos y hacer un calculo global y guardarlo 
en el campo total, creanme que voy dias en esto y no logro realizarlo. les 
agradezco su ayuda

English:
What I want is to put the amounts and then do the operation with respect to 
price calculation and make a single place in total,
eg cantidad_adulto enter 2 and from behind multiply with 7.50 being the 
value and thus to each and make a global calculation and store in the total 
field, trust me you'll days on this and I can not do it. thank you for your 
help


La base de datos es esta:




y este es el código de la vista: add.ctp



Form->create('Venta'); ?>





Form->input('nombre');

echo $this->Form->input('apellido');

echo $this->Form->input('cedula');

echo $this->Form->input('direccion');

echo $this->Form->input('mail');

echo $this->Form->input('telefono');

echo $this->Form->input('tarjeta');

echo $this->Form->input('numtarjeta');

echo __('SELECCIONE SU PELICULA'); 

echo $this->Form->input('cartelera_id',array('label' => 'Seleccione su 
pelicula'));//el array permite modificar los atributos del formulario en 
este caso el label para modificar el nombre del campo que bake arroja de 
forma magica

echo $this->Form->input('cant_adulto', array('label' => 'Cantidad de 
boletos - Precio normal $ 7,50'));

echo $this->Form->input('cant_niño', array('label' => 'Cantidad de boletos 
- Precio niños/ancianos $ 5,50'));

echo $this->Form->input('cant_discapacitado', array('label' => 'Cantidad de 
boletos - Precio discapacitados $ 4,90'));



echo __('SELECCIONE SU COMBO'); 

echo $this->Form->input('combo_id');

echo $this->Form->input('numcombo', array('label' => 'Cantidad de combos - 
Precio discapacitados $ 12,90'));

echo $this->Form->input('total');

?>







Form->end(__('Guardar')); ?>











Html->link(__('Listar Ventas'), array('action' => 
'index')); ?>

Html->link(__('Listar Clientes'), array('controller' 
=> 'clientes', 'action' => 'index')); ?> 

Html->link(__('Nuevo Cliente'), array('controller' => 
'clientes', 'action' => 'add')); ?> 

Html->link(__('Listar Combos'), array('controller' => 
'combos', 'action' => 'index')); ?> 

Html->link(__('Nuevo Combo'), array('controller' => 
'combos', 'action' => 'add')); ?> 

Html->link(__('Listar Carteleras'), 
array('controller' => 'carteleras', 'action' => 'index')); ?> 

Html->link(__('Nueva Cartelera'), array('controller' 
=> 'carteleras', 'action' => 'add')); ?> 





-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Get blackholed all my forms functions on servers

2014-06-03 Thread Victor Vargas
Hi all!,

This is my problem, I have try on my local server simple forms with the 
security component, and they work perfectly.
But I try this on my 1and1 server and i get blackholed this form.

Any idea?

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


RE: Validate Dynamic Forms

2014-05-22 Thread Advantage+
Sorry that makes no sense. Add or remove from what fieldname since we do not 
know the name? How do you validate the name of the field when the name is 
generated dynamically?

 

User makes a quiz with 20 questions,  15 questions that will need a text area, 
the other 5 are yes/no radio inputs. 

There are no names such as password, email as you noted in overriding 
validation the fields are dynamic so there is no way to know the name to 
hardcode it ahead of time.

 

Field names end up being : " name="data[Question][q-123asd569yhu]", we do not 
know the names of the fields

 









…… and so on



 

 

From: cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] On Behalf Of 
Stephen S
Sent: Thursday, May 22, 2014 4:56 PM
To: cake-php@googlegroups.com
Subject: Re: Validate Dynamic Forms

 

You can add and remove validation rules on the fly before you check if the form 
is valid.

 

http://book.cakephp.org/2.0/en/models/data-validation.html#dynamically-change-validation-rules

 

On 22 May 2014 19:50, Advantage+  wrote:

I am building a questionnaire where the user can add questions to a form 
(either yes or no or text answer response)

So the Question has id, quiz_id, question, type (text or true / false),

 

But how would you validate this?

 

In the view I simply do a foreach ($questions as $question){

echo $this->Form->input($question['question']['id'], array(

'label' => 
$question['Question']['question'],

'type' => 
$question['Question']['type'],

'div' => false));

 

But how do you validate this since model validation will not know these input / 
field names

The fieldname will be dynamic.

 

Thanks,

 

Dave

 

 

 

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.





 

-- 
Kind Regards

 Stephen Speakman

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: Validate Dynamic Forms

2014-05-22 Thread Stephen S
You can add and remove validation rules on the fly before you check if the
form is valid.

http://book.cakephp.org/2.0/en/models/data-validation.html#dynamically-change-validation-rules


On 22 May 2014 19:50, Advantage+  wrote:

> I am building a questionnaire where the user can add questions to a form
> (either yes or no or text answer response)
>
> So the Question has id, quiz_id, question, type (text or true / false),
>
>
>
> But how would you validate this?
>
>
>
> In the view I simply do a foreach ($questions as $question){
>
> echo $this->Form->input($question['question']['id'], array(
>
> 'label' =>
> $question['Question']['question'],
>
> 'type' =>
> $question['Question']['type'],
>
> 'div' => false));
>
>
>
> But how do you validate this since model validation will not know these
> input / field names
>
> The fieldname will be dynamic.
>
>
>
> Thanks,
>
>
>
> Dave
>
>
>
>
>
>
>
> --
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
>
> ---
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to cake-php+unsubscr...@googlegroups.com.
> To post to this group, send email to cake-php@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Kind Regards
 Stephen Speakman

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Validate Dynamic Forms

2014-05-22 Thread Advantage+
I am building a questionnaire where the user can add questions to a form
(either yes or no or text answer response)

So the Question has id, quiz_id, question, type (text or true / false),

 

But how would you validate this?

 

In the view I simply do a foreach ($questions as $question){

echo $this->Form->input($question['question']['id'], array(

'label' =>
$question['Question']['question'],

'type' =>
$question['Question']['type'],

'div' => false));

 

But how do you validate this since model validation will not know these
input / field names

The fieldname will be dynamic.

 

Thanks,

 

Dave

 

 

 

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Question about cakephp forms and JS

2014-02-26 Thread Thomas Goeminne
Hi,

I am trying to make a form which collects data on submit. Maybe someone can 
help me.

I have a  

Then I have a form:

Form->create('Drawing');
echo $this->Form->input('id');
echo $this->Form->input('name');
echo $this->Form->input('description');
echo $this->Form->input('canvas');
echo $this->Form->end(__('Submit'));
?>

When the user clicks submit, I want the page to collect the canvas data, 
and send it along with the rest of the post data.

How would I do this?

var canvas = document.getElementById('canvas');
var dataURL = canvas.toDataURL();

Also after submit I would like to store it. Normally I use the upload 
plugin from Jose gonzalez, but not sure if it can handle the raw data. So 
maybe I need save it first to the server. This will not be a problem. The 
main problem is how I can get the dataURL into the forms canvas. 

Greets,
Thomas


-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Questions regarding editing data in forms

2014-01-06 Thread Stephen S
Hey RoadRunner

I'm not sure I would use named parameters to update records like that, I
understand your concern and I think I would share the same concerns.

It sounds like you want to be able to edit multiple records in place
without having to view each individual record in a edit page, and go
through a form. If that is the case there may be several ways to do this,
ajax is probably the best way.

Make it so the data is sent to the server in the background and lock the
controller action so it only edits the record when it detects ajax (if
($this->request->is('ajax'){ .. }). This way if you sent an ajax request to
/controller/edit/$id/$newValue it wouldn't work if the browser just hit the
URL.

Something I have used before for actually editing fields is X-Editable for
Twitter Bootstrap. It works pretty nicely with CakePHP if you do use
Twitter Bootstrap: http://vitalets.github.io/x-editable/

It's hard for me to suggest much else without actual code snippets.

Kind Regards
 Stephen


On 6 January 2014 02:35, RoadRunner  wrote:

> Hi,
>
> i'm new to CakePHP and try to build my first database application. So far
> i can list all customers in my test-database and view/edit a customer via a
> link with the customer id passed as a named parameter.
>
> At the moment i have 2 links to different controllers in each row of the
> customer list, one for viewing the data and one for editing the data. The
> layout looks almost equal for both controllers, which is important for me,
> but in the controller for viewing the data the form input elements are
> readonly.
> Is it possible to edit a record after it is displayed readonly instead of
> placing an edit link in each row of the customer list? Of course i can
> place my edit link inside the displayed record instead of placing it inside
> each row, but this way i allways have 2 different controller with nearly
> identical views, one with read only input elements and one with editable
> input elements. Is this the best way to do this?
>
> Then i noticed that all the controllers, actions and my named parameters
> are visible within the URL and that i'm able to edit values and call
> functions without clicking a button. Isn't it dangerous to pass parameters
> within the URL when i let users work with my database application?
> I don't mean deliberately tampering the database records in the first
> place, but rather getting trouble because they use the browser history or
> bookmarks or they close the browser tab accidently. Users often try so many
> stupid things we can't imagine...is there a simple solution how i can
> harden the application against such dangers/mistakes? I would prefer it
> when the users can only "walk" through the application in the prescribed
> manner and that i can detect deviant behaviour and either reload the last
> page or discard the last action and start from scratch. Does this also mean
> that i should work with transactions to keep the database consistent?
>
> Best regards,
> RoadRunner
>
>  --
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
>
> ---
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to cake-php+unsubscr...@googlegroups.com.
> To post to this group, send email to cake-php@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php.
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 
Kind Regards
 Stephen Speakman

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.


Questions regarding editing data in forms

2014-01-06 Thread RoadRunner
Hi,

i'm new to CakePHP and try to build my first database application. So far i 
can list all customers in my test-database and view/edit a customer via a 
link with the customer id passed as a named parameter.

At the moment i have 2 links to different controllers in each row of the 
customer list, one for viewing the data and one for editing the data. The 
layout looks almost equal for both controllers, which is important for me, 
but in the controller for viewing the data the form input elements are 
readonly.
Is it possible to edit a record after it is displayed readonly instead of 
placing an edit link in each row of the customer list? Of course i can 
place my edit link inside the displayed record instead of placing it inside 
each row, but this way i allways have 2 different controller with nearly 
identical views, one with read only input elements and one with editable 
input elements. Is this the best way to do this?

Then i noticed that all the controllers, actions and my named parameters 
are visible within the URL and that i'm able to edit values and call 
functions without clicking a button. Isn't it dangerous to pass parameters 
within the URL when i let users work with my database application?
I don't mean deliberately tampering the database records in the first 
place, but rather getting trouble because they use the browser history or 
bookmarks or they close the browser tab accidently. Users often try so many 
stupid things we can't imagine...is there a simple solution how i can 
harden the application against such dangers/mistakes? I would prefer it 
when the users can only "walk" through the application in the prescribed 
manner and that i can detect deviant behaviour and either reload the last 
page or discard the last action and start from scratch. Does this also mean 
that i should work with transactions to keep the database consistent?

Best regards,
RoadRunner

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.


Submitting FormHelper forms in Internet Explorer 8

2013-07-13 Thread Kieran Barnes
I have a Cake 2.2.8 application with a whole collection of forms. All work 
perfectly in IE9/Chrome/usual suspects.

When submitting a form in IE8, it doesn't work, just reloads the page.

The add method for the controller method code is fairly basic;

public function add() {
// KB added for test
debug($_REQUEST);
debug($this->request);
debug($_POST);
debug($_SERVER);

if( $this->request->is('post') ) {
$this->request->data['User']['created_by'] = 
$this->Auth->user('id');

if($this->Auth->user('group_id') == 2) {
$this->User->addAdditionalValidationRulesForStaff();
}

$this->User->create();
if( $this->User->save($this->request->data) ) {
$this->flashSuccess(__('The user has been saved'));
$this->redirect(array('action' => 'index'));
} else {
$this->flashFailure(__('The user could not be saved. 
Please, try again.'));
}
}

$this->_setLists();
}

Again, it works fine in all browsers except IE 8. The output of 
debug($_SERVER); shows 'REQUEST_METHOD' => 'GET', in IE8, whilst other 
browsers show 'REQUEST_METHOD' => 'POST'
debug($_POST) is empty in IE 8 and is populated in other browsers.

The form view code is quite basic too

Form->create('User'); ?>
...
Form->Submit(ucwords($this->params["action"]).' 
'.ucwords(Inflector::singularize($this->params["controller"])),array('div' 
=> false, 'class' => 'btn btn-info')); ?>
Form->end(); ?>

Incidentally the identical "Edit" method works fine.
Other controllers are also affected by this issue.

Has anyone else experienced this issue? Or know how to fix it?

Thanks

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.




HABTM and forms

2013-06-25 Thread Gabriele Carioli
Hi everybody,

I'm struggling with a particular hasAndBelongsToMany form data problem and 
need some help.

Quickly:

1. A recipe can have many ingredients.
2. An ingredient can be in many recipes.
2. An ingredient in a recipe can be mandatory or optional (or not present).
4. an ingredient in a recipe should be present in a certain weight.

I don't simply need to add or remove ingredients but also to set some value 
for each of them.

These are my tables:

CREATE TABLE `ingredients` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`id`)
)

CREATE TABLE `recipes` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`id`)
)

CREATE TABLE `ingredients_recipes` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `recipe_id` int(10) NOT NULL DEFAULT '0',
  `ingredient_id` int(10) NOT NULL DEFAULT '0',
  `mandatory` enum('M','O') DEFAULT NULL,
  `weight` int(10) DEFAULT '0',
  PRIMARY KEY (`id`)
)

There's an obvious hasAndBelongsToMany relation between recipes and 
ingredients.
I guess models could be something like this:

class Recipe extends AppModel
{
public $hasAndBelongsToMany = array('Ingredient');
}

class Ingredient extends AppModel
{
public $hasAndBelongsToMany = array('Recipe');
}


When I edit a recipe, I would like to select each single ingredient from a 
list.
In each line of the list I would like to have three radio buttons (or a 
"select" with three values) and a in input field for the weight:

  (*) do not select
  ( ) mandatory
  ( ) optional

  weight: N

Values are validated before saving. If "do not select" is set, the row is 
not saved (or deleted, if present).


Can anybody please suggest me some sample controller and view code for 
implementing such a form?


-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Multiple Forms on the same form

2013-03-28 Thread david . suna
I have done this using AJAX.  Have the button fire an AJAX event which 
calls an action on your controller which returns an empty workcenter 
section of the field.  Pass in to the AJAX call an index and have the form 
fields specified using the index.  When the form is submitted you would 
then have an array of workcenters as part of your data and you can use 
saveAll to save the factory model and all related models (assuming you have 
set up a hasMany / belongsTo relationship between factory and workcenter).

Just remember that when editing a factory you will need to present all of 
the existing workcenters associated with it as well.

On Sunday, March 24, 2013 7:54:37 PM UTC+2, Steven Scaffidi wrote:
>
> Let's say I had a model called factory, and I wanted to add multiple 
> workcenters to the factory. When I go to add a new factory, I want a button 
> on the bottom of my form that says add workcenter. I want that button to be 
> always there just in case they want to add multiple work centers. I don't 
> want the form for workcenter to appear until they click the button add 
> workcenter. How can I accomplish this?
>
>
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

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




Multiple Forms on the same form

2013-03-24 Thread Steven Scaffidi
Let's say I had a model called factory, and I wanted to add multiple 
workcenters to the factory. When I go to add a new factory, I want a button 
on the bottom of my form that says add workcenter. I want that button to be 
always there just in case they want to add multiple work centers. I don't 
want the form for workcenter to appear until they click the button add 
workcenter. How can I accomplish this?


-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

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




Re: Getting values from forms

2013-02-13 Thread Yvon-René Blanchard
What is the error you get?

What is the query that is passed to the db?  $f is what before is been sent?

On Sunday, February 10, 2013 11:38:36 AM UTC-5, Diego Turcios wrote:
>
> Hi
>
> I need a view with two textbox for getting this values for doing a query
>
> This is my view reporteiario.ctp
>
>> Reporte Diario Form->create('dates'); echo 
>> $this->Form->input('Inicio'); echo $this->Form->input('Fin'); echo $this
>> ->Form->end('Generar Reporte'); ?>
>
>
> This is my function in my controller
> public function reportediario() { if ($this->request->is('post')) { $d=
> $this->request->data['dates']['inicio']; $q = "SELECT * from table WHERE 
> Fecha >= "; $f=$q.$d; $this->set('vwrecords',$this->Vwrecord->query($f) 
> ); } 
>>
>> }
>
>
> The problem is I am getting a database error. I can't request the data 
> from the text box.
> Any idea? 
>
>>  
>
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

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




Re: Getting values from forms

2013-02-13 Thread Varahalu Naidu Alugubilli
ve the same problem in cake php, can you explain how u did that? plz... 
reply to avnaidu...@gmail.com

On Sunday, February 10, 2013 10:08:36 PM UTC+5:30, Diego Turcios wrote:
>
> Hi
>
> I need a view with two textbox for getting this values for doing a query
>
> This is my view reporteiario.ctp
>
>> Reporte Diario Form->create('dates'); echo 
>> $this->Form->input('Inicio'); echo $this->Form->input('Fin'); echo $this
>> ->Form->end('Generar Reporte'); ?>
>
>
> This is my function in my controller
> public function reportediario() { if ($this->request->is('post')) { $d=
> $this->request->data['dates']['inicio']; $q = "SELECT * from table WHERE 
> Fecha >= "; $f=$q.$d; $this->set('vwrecords',$this->Vwrecord->query($f) 
> ); } 
>>
>> }
>
>
> The problem is I am getting a database error. I can't request the data 
> from the text box.
> Any idea? 
>
>>  
>
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

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




Getting values from forms

2013-02-10 Thread Diego Turcios


Hi

I need a view with two textbox for getting this values for doing a query

This is my view reporteiario.ctp

> Reporte Diario Form->create('dates'); echo 
> $this->Form->input('Inicio'); echo $this->Form->input('Fin'); echo $this
> ->Form->end('Generar Reporte'); ?>


This is my function in my controller
public function reportediario() { if ($this->request->is('post')) { $d=$this
->request->data['dates']['inicio']; $q = "SELECT * from table WHERE Fecha 
>= "; $f=$q.$d; $this->set('vwrecords',$this->Vwrecord->query($f) ); } 
>
> }


The problem is I am getting a database error. I can't request the data from 
the text box.
Any idea? 

>  

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

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




HTML in forms

2013-01-16 Thread Advantage+
I have integrated CKEditor with a file browser / uploads and all that is
working fine except the actual image part.

 

If I used the editor to create a table, ul ol lists the html saves in the
database fine.

But whenever I insert an image the code gets encoded.

 

Example1: Random elements / table /lists saved to database, rendered view
shows fine

26

 

Example 2 Adding image

hello

 

So the image never gets displayed. 

View:



 

There is nothing for beforeSave() or edits to any of the data submitted.

 

I cannot firure out why it only escapes the Img tag but all other HTML is
fine.

 

Any ideas how to escape => false for input? Or suggestions to fix this?

 

Thanks,

Dave

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
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.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




RE: Correct way to handle ajax forms

2013-01-01 Thread Advantage+
In my form I also do the same thing to switch the open / closing with an if
statement for the add or edit that's being called.

-Original Message-
From: cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] On Behalf
Of lowpass
Sent: Tuesday, January 01, 2013 4:32 PM
To: cake-php@googlegroups.com
Subject: Re: Correct way to handle ajax forms

I haven't done much AJAX stuff with 2.2.x yet but that's basically what I've
always been doing. Generally, my add and edit templates just include the
form.ctp element. In that I have a
switch($this->params['action']) to decide how to open/close the form.
But the point is to be able to render and return just the form portion of a
view.

On Tue, Jan 1, 2013 at 1:45 PM, Advantage+  wrote:
> Just wondering what is the correct way to handle processing forms 
> submitted via ajax / json response?
>
>
>
> What I have been doing is converting my add / edit forms into a single 
> element and placing them into the view/add/edit where needed so on 
> error all I need to do is return the form element or on success 
> whatever is needed success message.
>
>
>
> In the controller :
>
>
>
> if ( $this->Model->save($this->request->data, true)) {
>
>
>
> $response = array(
>
> 'status' => true,
>
> 'html' => 
> $this->render($this->autoElement('added_block'))->body(),
>
> 'message' => 'Saved!');
>
> } else {
>
>
>
> $this->set('errors', $this->Model->validationErrors);
>
> $response = array(
>
> 'status' => false,
>
> 'html' => 
> $this->render($this->autoElement('form'))->body(),
>
> 'message' =>  'Please 
> correct the following errors and try again!' );
>
> }
>
> $this->_ajaxReturn( $response ); //simply encodes $response array to 
> json that gets passed to the js
>
>
>
> This way the js can act according to the response status and has all 
> the HTML info ready to drop into my  or where ever and has all 
> the Cake inputs with errors. Is this going about it wrong? Or is there an
easier way?
>
> Just curious how others are approaching this.
>
>
>
> Thanks,
>
>
>
> Dave
>
> --
> Like Us on FaceBook https://www.facebook.com/CakePHP Find us on 
> Twitter http://twitter.com/CakePHP
>
> ---
> 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.
> Visit this group at http://groups.google.com/group/cake-php?hl=en.
>
>

--
Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter
http://twitter.com/CakePHP

---
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.
Visit this group at http://groups.google.com/group/cake-php?hl=en.



-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
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.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: Correct way to handle ajax forms

2013-01-01 Thread lowpass
I haven't done much AJAX stuff with 2.2.x yet but that's basically
what I've always been doing. Generally, my add and edit templates just
include the form.ctp element. In that I have a
switch($this->params['action']) to decide how to open/close the form.
But the point is to be able to render and return just the form portion
of a view.

On Tue, Jan 1, 2013 at 1:45 PM, Advantage+  wrote:
> Just wondering what is the correct way to handle processing forms submitted
> via ajax / json response?
>
>
>
> What I have been doing is converting my add / edit forms into a single
> element and placing them into the view/add/edit where needed so on error all
> I need to do is return the form element or on success whatever is needed
> success message.
>
>
>
> In the controller :
>
>
>
> if ( $this->Model->save($this->request->data, true)) {
>
>
>
> $response = array(
>
> 'status' => true,
>
> 'html' =>
> $this->render($this->autoElement('added_block'))->body(),
>
> 'message' => 'Saved!');
>
> } else {
>
>
>
> $this->set('errors', $this->Model->validationErrors);
>
> $response = array(
>
> 'status' => false,
>
> 'html' =>
> $this->render($this->autoElement('form'))->body(),
>
> 'message' =>  'Please
> correct the following errors and try again!' );
>
> }
>
> $this->_ajaxReturn( $response ); //simply encodes $response array to json
> that gets passed to the js
>
>
>
> This way the js can act according to the response status and has all the
> HTML info ready to drop into my  or where ever and has all the Cake
> inputs with errors. Is this going about it wrong? Or is there an easier way?
>
> Just curious how others are approaching this.
>
>
>
> Thanks,
>
>
>
> Dave
>
> --
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
>
> ---
> 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.
> Visit this group at http://groups.google.com/group/cake-php?hl=en.
>
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
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.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Correct way to handle ajax forms

2013-01-01 Thread Advantage+
Just wondering what is the correct way to handle processing forms submitted
via ajax / json response?

 

What I have been doing is converting my add / edit forms into a single
element and placing them into the view/add/edit where needed so on error all
I need to do is return the form element or on success whatever is needed
success message.

 

In the controller :

 

if ( $this->Model->save($this->request->data, true)) {

 


$response = array(

'status' => true,

'html' =>
$this->render($this->autoElement('added_block'))->body(),

'message' => 'Saved!');

} else {

 


$this->set('errors', $this->Model->validationErrors);

$response = array(

'status' => false,

'html' =>
$this->render($this->autoElement('form'))->body(),

'message' =>  'Please
correct the following errors and try again!' );

}

$this->_ajaxReturn( $response ); //simply encodes $response array to json
that gets passed to the js

 

This way the js can act according to the response status and has all the
HTML info ready to drop into my  or where ever and has all the Cake
inputs with errors. Is this going about it wrong? Or is there an easier way?

Just curious how others are approaching this.

 

Thanks,

 

Dave

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
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.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: Using jQuery.ajax - Sending non-forms values to server

2012-11-29 Thread Blues Clues
Hi Miles
You are the man. I have been pulling my hair over this, wanting to send 
parameters to my jquery calls without using some temporary form. 
I am so happy today.
Thank you, thank you and thank you.
-Sri Adhi

On Wednesday, April 22, 2009 5:17:58 PM UTC-4, Miles J wrote:
>
> You have to send it within a data array like so: 
>
> jQuery.ajax({ 
> type: "POST", 
> url: '/controller/action', 
> data: "data[Model][name]=value&data[name]=value" 
> }); 
>
> And in the controller: 
>
> $this->data['Model']['name'] OR 
> $this->data['name']

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
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.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: Login Forms

2012-07-13 Thread Sam Sherlock
get the login working within the users controller

have auth set in app controller - set login redirecto to pages display home

include the login for in home.ctp via an elemet (the form points to users
login)

also pages does have a controller its just does not use a model (add
parent::beforeFilter to this controller)

 - S





On 13 July 2012 18:03, Andrew Johnston  wrote:

> Thanks Steve, but that doesn't quite answer my question. Can home.ctp be a
> login page? As it has no controller I don't know where I could put the Auth
> components.
>
> Andrew
>
>
> On Friday, July 13, 2012 7:42:27 AM UTC-4, Steve wrote:
>>
>> You can use a Eagle User Management Plugin that gives Login options. I am
>> using a great Plugin original cost $197 , now at an offer price of 30$
>> which gives Login with FB, Twitter, Foursquare, LinkedIn, Google, Yahoo and
>> it has 56 more features. Check website http://www.eagle.**
>> getyourplugin.com <http://www.eagle.getyourplugin.com>
>>
>> On Friday, July 13, 2012 2:29:47 AM UTC+5:30, Andrew Johnston wrote:
>>>
>>> Hello Everyone-
>>>
>>> I'm new to CakePHP and I'm a bit confused with the idea of login forms.
>>> I've read just about every page I could find on the issue, but none of them
>>> seemed to mirror my problem exactly.
>>>
>>> I'm using Wordpress for the static portion of my site and I wanted to
>>> have a link that said "Login". Upon clicking the link it would take the
>>> user to a form with the standard email/password boxes. When the user
>>> submitted the data, only then would it pass it over solely to the web app,
>>> which would verify the user, log them in, and redirect them to the home
>>> page of the web app. Is this possible?
>>>
>>> Follow up question: If it would be easier/possible, can I modify my
>>> home.ctp to be a login form? If so, how?
>>>
>>> Thank you everyone for bearing with me as I struggle through this. I
>>> love Cake and it really is making my job easier!
>>>
>>  --
> 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
>

-- 
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: Login Forms

2012-07-13 Thread Andrew Johnston
Thanks Steve, but that doesn't quite answer my question. Can home.ctp be a 
login page? As it has no controller I don't know where I could put the Auth 
components. 

Andrew

On Friday, July 13, 2012 7:42:27 AM UTC-4, Steve wrote:
>
> You can use a Eagle User Management Plugin that gives Login options. I am 
> using a great Plugin original cost $197 , now at an offer price of 30$ 
> which gives Login with FB, Twitter, Foursquare, LinkedIn, Google, Yahoo and 
> it has 56 more features. Check website http://www.eagle.getyourplugin.com
>
> On Friday, July 13, 2012 2:29:47 AM UTC+5:30, Andrew Johnston wrote:
>>
>> Hello Everyone-
>>
>> I'm new to CakePHP and I'm a bit confused with the idea of login forms. 
>> I've read just about every page I could find on the issue, but none of them 
>> seemed to mirror my problem exactly. 
>>
>> I'm using Wordpress for the static portion of my site and I wanted to 
>> have a link that said "Login". Upon clicking the link it would take the 
>> user to a form with the standard email/password boxes. When the user 
>> submitted the data, only then would it pass it over solely to the web app, 
>> which would verify the user, log them in, and redirect them to the home 
>> page of the web app. Is this possible?
>>
>> Follow up question: If it would be easier/possible, can I modify my 
>> home.ctp to be a login form? If so, how?
>>
>> Thank you everyone for bearing with me as I struggle through this. I love 
>> Cake and it really is making my job easier! 
>>
>

-- 
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: Login Forms

2012-07-13 Thread Rohit
You can use a Eagle User Management Plugin that gives Login options. I am 
using a great Plugin original cost $197 , now at an offer price of 30$ 
which gives Login with FB, Twitter, Foursquare, LinkedIn, Google, Yahoo and 
it has 56 more features. Check website http://www.eagle.getyourplugin.com

On Friday, July 13, 2012 2:29:47 AM UTC+5:30, Andrew Johnston wrote:
>
> Hello Everyone-
>
> I'm new to CakePHP and I'm a bit confused with the idea of login forms. 
> I've read just about every page I could find on the issue, but none of them 
> seemed to mirror my problem exactly. 
>
> I'm using Wordpress for the static portion of my site and I wanted to have 
> a link that said "Login". Upon clicking the link it would take the user to 
> a form with the standard email/password boxes. When the user submitted the 
> data, only then would it pass it over solely to the web app, which would 
> verify the user, log them in, and redirect them to the home page of the web 
> app. Is this possible?
>
> Follow up question: If it would be easier/possible, can I modify my 
> home.ctp to be a login form? If so, how?
>
> Thank you everyone for bearing with me as I struggle through this. I love 
> Cake and it really is making my job easier! 
>

-- 
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


Login Forms

2012-07-13 Thread Andrew Johnston
Hello Everyone-

I'm new to CakePHP and I'm a bit confused with the idea of login forms. 
I've read just about every page I could find on the issue, but none of them 
seemed to mirror my problem exactly. 

I'm using Wordpress for the static portion of my site and I wanted to have 
a link that said "Login". Upon clicking the link it would take the user to 
a form with the standard email/password boxes. When the user submitted the 
data, only then would it pass it over solely to the web app, which would 
verify the user, log them in, and redirect them to the home page of the web 
app. Is this possible?

Follow up question: If it would be easier/possible, can I modify my 
home.ctp to be a login form? If so, how?

Thank you everyone for bearing with me as I struggle through this. I love 
Cake and it really is making my job easier! 

-- 
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: Best practices for AJAX forms

2012-06-25 Thread lowpass
Your two options are essentially the same thing. Either way, you're
making a request to the controller. Another option would be to include
the form in the view from the start, but hide it.

Personally, what I usually do is have jquery intercept the edit link
and make an AJAX request instead using the link's href (which passes
the ID of the thing I want to edit).

I make the form itself an element which is included into my add & edit
views with $this->element('form').

So in the controller I set $layout to false and change $viewPath to,
eg. 'elements'.DS.'Products' and then call $this->render('form') to
send it back as the AJAX response.

On Mon, Jun 25, 2012 at 7:15 AM, Florin Trifu
 wrote:
> Hi
>
> On my page, I have a table with the information of a company and a
> button to edit the information. On click, through jQuery and AJAX, I
> want to transform that table into a form, and I can do that either by
> adding the form with javascript (hard coding it in javascript and
> requesting from the server via AJAX the information from the database)
> or by making a request to the controller and load the form.
>
> Which one do you think is better from the best practices point of
> view?
>
> Thank you in advance!
>
> --
> 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

-- 
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


Best practices for AJAX forms

2012-06-25 Thread Florin Trifu
Hi

On my page, I have a table with the information of a company and a
button to edit the information. On click, through jQuery and AJAX, I
want to transform that table into a form, and I can do that either by
adding the form with javascript (hard coding it in javascript and
requesting from the server via AJAX the information from the database)
or by making a request to the controller and load the form.

Which one do you think is better from the best practices point of
view?

Thank you in advance!

-- 
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: Cached Forms Don't Submit

2011-11-06 Thread BlenderStyle
Dividing the form into two actions, one to display and one to save,
did the trick. Thanks for the help, 0x20h. I appreciate it.

On Oct 30, 12:11 pm, 0x20h  wrote:
> When beforeFilter() gets called cake is already rendering the "cached
> version".
> (see dispatcher::cached() and ViewHelper#__writeFile()).
> Regarding to the docs its not recommended to use the callbacks 
> (http://book.cakephp.org/view/1380/Caching-in-the-Controller) .
> I would probably try to separate the "display" and "save" part into 2
> actions or put theforminto an
> element andcachethat element manually, not via cacheAction.
> e.g. in your view script
>
> if($this->data || !($content =Cache::read('big_form', 'persistent'))) {
>     $content = $this->element('big_form');
>     if (!$this->data) {
>        Cache::write('big_form', $content, 'persistent');
>     }}
>
> echo $content;
>
> Am 30.10.2011 19:26, schrieb BlenderStyle:
>
>
>
>
>
>
>
> > I have setup the index and edit actions to be cached in my
> > PostsController as follows:
>
> > var $cacheAction = array(
> >    'index' => array('callbacks' => true, 'duration' => '7 days'),
> >    'edit' => array('callbacks' => true, 'duration' => '7 days'),
> > );
>
> > Everything is cached as expected, but the editformdoesn'tsubmit.
> > This is expected as well, if you think about it, but is there anyway
> > to bypass caching when a user submits aform?
>
> > I set callbacks to true to allow AuthComponent to do its magic, so if
> > I could put some code in beforeFilter(), it's executed dynamically
> > (not cached). I have tried each of the following in beforeFilter(),
> > one by one, but none of them did the trick:
>
> > if(!empty($this->data)) clearCache();
> > if(!empty($this->data)) Configure::write('Cache.check', false);
> > if(!empty($this->data)) $this->cacheAction = false;
>
> > To avoid the "why would you even want to do that" argument I see in
> > other forums, I'll explain a little further. My edit action is fairly
> > intensive since it's such a longformwith a lot of "stuff" in it and
> > caching definitely improves the performance. To avoid writing extra
> > code, the edit action displays theformas well as saves it.

-- 
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: Cached Forms Don't Submit

2011-10-30 Thread 0x20h
When beforeFilter() gets called cake is already rendering the "cached
version".
(see dispatcher::cached() and ViewHelper#__writeFile()).
Regarding to the docs its not recommended to use the callbacks (
http://book.cakephp.org/view/1380/Caching-in-the-Controller ) .
I would probably try to separate the "display" and "save" part into 2
actions or put the form into an
element and cache that element manually, not via cacheAction.
e.g. in your view script

if($this->data || !($content = Cache::read('big_form', 'persistent'))) {
$content = $this->element('big_form');
if (!$this->data) {
Cache::write('big_form', $content, 'persistent');
}
}
echo $content;



Am 30.10.2011 19:26, schrieb BlenderStyle:
> I have setup the index and edit actions to be cached in my
> PostsController as follows:
>
> var $cacheAction = array(
>   'index' => array('callbacks' => true, 'duration' => '7 days'),
>   'edit' => array('callbacks' => true, 'duration' => '7 days'),
> );
>
> Everything is cached as expected, but the edit form doesn't submit.
> This is expected as well, if you think about it, but is there anyway
> to bypass caching when a user submits a form?
>
> I set callbacks to true to allow AuthComponent to do its magic, so if
> I could put some code in beforeFilter(), it's executed dynamically
> (not cached). I have tried each of the following in beforeFilter(),
> one by one, but none of them did the trick:
>
> if(!empty($this->data)) clearCache();
> if(!empty($this->data)) Configure::write('Cache.check', false);
> if(!empty($this->data)) $this->cacheAction = false;
>
> To avoid the "why would you even want to do that" argument I see in
> other forums, I'll explain a little further. My edit action is fairly
> intensive since it's such a long form with a lot of "stuff" in it and
> caching definitely improves the performance. To avoid writing extra
> code, the edit action displays the form as well as saves it.
>


-- 
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


Cached Forms Don't Submit

2011-10-30 Thread BlenderStyle
I have setup the index and edit actions to be cached in my
PostsController as follows:

var $cacheAction = array(
'index' => array('callbacks' => true, 'duration' => '7 days'),
'edit' => array('callbacks' => true, 'duration' => '7 days'),
);

Everything is cached as expected, but the edit form doesn't submit.
This is expected as well, if you think about it, but is there anyway
to bypass caching when a user submits a form?

I set callbacks to true to allow AuthComponent to do its magic, so if
I could put some code in beforeFilter(), it's executed dynamically
(not cached). I have tried each of the following in beforeFilter(),
one by one, but none of them did the trick:

if(!empty($this->data)) clearCache();
if(!empty($this->data)) Configure::write('Cache.check', false);
if(!empty($this->data)) $this->cacheAction = false;

To avoid the "why would you even want to do that" argument I see in
other forums, I'll explain a little further. My edit action is fairly
intensive since it's such a long form with a lot of "stuff" in it and
caching definitely improves the performance. To avoid writing extra
code, the edit action displays the form as well as saves it.

-- 
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: Embedded forms, model inheritance

2011-10-19 Thread daf182
Hi,

First of all I forgot to mention that I'm using CakePhP 2.0, PHP
5.3.1, and MySQL5.1.41, and Apache 2.2.14.
Some investigation has been done.
So the validation inhereted from the parent model is working. The only
thing I had to do is to no to put the name of the parent model on the
view as I mentioned.

so just simply use:
Form->create('ModelB');?>


Form->input('field1FromA'); // no need to use
ModelA.field1FromA
echo $this->Form->input('field2FromA');
// etc...
echo $this->Form->input('field1FromB');
echo $this->Form->input('field2FromB');
// etc...
?>

Form->end(__('Submit'));?>

This would be pretty cool, but some problem still exist. The form is
based on ModelB, and Form->input(...) function tries to figure out
which type the given field is. This works perfectly for the fields of
the given model but not its parent. It will not see the underlying
table of ModelA so eg. TINYINT(1) is not discovered well and simple
text input is showed instead of a checkbox. But, if I specify the
model in the view the checkbox appears well. (but the validation goes
away...).
I check the dump of the $object retrieved in _introspectModel() in
FormHelper.php which has type eg. ModelB. The validation part of the
dumped array seems ok, contains both rules from the child model and
from the parent model. The problem is that the useTable and table part
contain only the table used by ModelB, models_bs. If I take a closer
look at that object dump (printed by debug($object);) I found
parentClass, and parent. If it does not find the attribute in the
model and in the models joind to it (via habtm), it could look for
them in the model's parent. So this part should be corrected:
if ($key === 'fields') {
if (!isset($this->fieldset[$model]['fields'])) {
$fields = 
$this->fieldset[$model]['fields'] = $object->schema();
}
if (empty($field)) { // it's not my case now
foreach ($object->hasAndBelongsToMany 
as $alias => $assocData) {

$this->fieldset[$object->alias]['fields'][$alias] = array('type'
=> 'multiple');
}
return 
$this->fieldset[$model]['fields'];
} elseif 
(isset($this->fieldset[$model]['fields'][$field])) { //
returns here in success
return 
$this->fieldset[$model]['fields'][$field];
} else {
// it returns here if the give field is not found, inhereted fields
should be handled from here
return 
isset($object->hasAndBelongsToMany[$field]) ? array('type'
=> 'multiple') : null;
}
}

Hope this will help to somebody.

On okt. 18, 21:58, Gergő Nagy  wrote:
> Hi,
>
> I did not find any material about inheritance, and form embedding on cake
> php sites so far.
> I tried to use 
> this:http://bakery.cakephp.org/articles/santino83/2011/02/19/behavior_for_...
> but did not work perfectly.
> Basicly I use MTI (multiple table inheritance)
> I have classes ModelA extends AppModel, class ModelB extends ModelA, class
> ModelC extends ModelA and class ModelD extends AppModel.
> Let's say ModelA  belongsTo ModelD and ModelD hasMany ModelA of course.
>
> Tables:
> model_as(id, model_d_id, ...)
> model_bs(id, ...)
> model_cs(id, ...)
> model_ds(id, ...)
>
> Id fields in model_bs and model_cs are the same as in model_as. So before we
> can save a ModelB entity we have to save ModelA to have common id. This is
> handled more or less by that behavior mentioned above. (One bug exists
> related to this.)
>
> Is there any built in support from cake php, to support this kind of
> architecture?
> What I would need from the child entites point of view are:
> - embedding the fields of the parent model on the child's form, now I put
> them there by hand. Like ModelA.field1, ModelA.field2, etc. while form is
> created eg. with $this->Form->create('ModelB')
> - validation defined in ModelA, disapperad in the view of the child entity
> - types of the fields of the parent class are not ok, on the parent form
> they are ok, but on the a child form they aren't. Eg. booleans became simple
> textfields.
> - fields that are come via relationship of ModelA belongsTo property from
> ModelD, has to be set by hand in the controller of ModelB
> - on the update form these kind of fields (mentioned in the previous line),
> are not field well, selected element has to be set by hand
>
> I used the $uses = ('ModelA', 'ModelB') in the controller of ModelB.
>
> So is there anybody who faces these situation or is it planned to be
> supported in cake php?

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp

Embedded forms, model inheritance

2011-10-18 Thread Gergő Nagy
Hi,

I did not find any material about inheritance, and form embedding on cake
php sites so far.
I tried to use this:
http://bakery.cakephp.org/articles/santino83/2011/02/19/behavior_for_model_inheritance_the_missing_feature
but did not work perfectly.
Basicly I use MTI (multiple table inheritance)
I have classes ModelA extends AppModel, class ModelB extends ModelA, class
ModelC extends ModelA and class ModelD extends AppModel.
Let's say ModelA  belongsTo ModelD and ModelD hasMany ModelA of course.

Tables:
model_as(id, model_d_id, ...)
model_bs(id, ...)
model_cs(id, ...)
model_ds(id, ...)

Id fields in model_bs and model_cs are the same as in model_as. So before we
can save a ModelB entity we have to save ModelA to have common id. This is
handled more or less by that behavior mentioned above. (One bug exists
related to this.)

Is there any built in support from cake php, to support this kind of
architecture?
What I would need from the child entites point of view are:
- embedding the fields of the parent model on the child's form, now I put
them there by hand. Like ModelA.field1, ModelA.field2, etc. while form is
created eg. with $this->Form->create('ModelB')
- validation defined in ModelA, disapperad in the view of the child entity
- types of the fields of the parent class are not ok, on the parent form
they are ok, but on the a child form they aren't. Eg. booleans became simple
textfields.
- fields that are come via relationship of ModelA belongsTo property from
ModelD, has to be set by hand in the controller of ModelB
- on the update form these kind of fields (mentioned in the previous line),
are not field well, selected element has to be set by hand

I used the $uses = ('ModelA', 'ModelB') in the controller of ModelB.

So is there anybody who faces these situation or is it planned to be
supported in cake php?

-- 
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: Node and attachment forms on single page

2011-10-03 Thread Constantin.FF
... I tried to
change the file input form with simple title and body fields, and to
remove the Attachable behavior form the AddAttachment behavior ... and
it is working, like this it add new row to the 'nodes' table with
correct title adn body

-- 
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


Node and attachment forms on single page

2011-10-03 Thread Constantin.FF
I have very simple Nodes model/view/controller which by default stores
information like Title, Body... To each Node I need attached images,
or other files. So I created a Uploads M/V/C with the attachable
behavior from phpvideotutorials: http://pastebin.com/87pQtgib
Now if I use the Uploads M/V/C I am able to upload images and store
some of image information in the 'uploads' table, but I need to set
the attachment form into the edit nodes pages and use the 'nodes'
table for the uploads.
So I read the information for multiple forms in same page:
http://bakery.cakephp.org/articles/RabidFire/2010/06/26/multiple-forms-per-page-for-the-same-model
I created:
models/add_attachment.php
---
 array( 'types' => array('image/
jpeg' => 'jpg', 'image/pjpeg' => 'jpg', 'application/zip' => 'zip')));
}
?>

views/nodes/admin_edit.ctp:
-

Form->create('Node');?>


Form->input('id');
echo $this->Form->input('title');
echo $this->Form->input('body');
?>

Form->end(__('Submit', true));?>
Form->create('AddAttachment', array('url' => '/
admin/nodes/add'));
echo $this->Form->input('attachment', array('type' => 'file'));
echo $this->Form->end('Upload');?>


controllers/nodes_controller.php
--
..
function admin_add() {
if (!empty($this->data)) {
   $this->loadModel('AddAttachment');
   if($this->data['AddAttachment']) {
$this->AddAttachment->create();
if ($this->AddAttachment->save($this->data)) {
$this->Session->setFlash(__('The node has been 
saved', true));
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The node could not 
be saved. Please,
try again.', true));
}
   } else {
$this->Node->create();
if ($this->Node->save($this->data)) {
$this->Session->setFlash(__('The node has been 
saved', true));
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The node could not 
be saved. Please,
try again.', true));
}
   }


}
}
..
(i pasted only the modified part)

As a result I get an error message when trying to upload a file:
--
Notice (8): Undefined index:  Node [APP/models/behaviors/
attachable.php, line 38]
Code | Context

  {

extract($this->settings[$model->name]);

$attachment = $model->data[$model->name][$label];

$model  =   AddAttachment
AddAttachment::$actsAs = array
AddAttachment::$name = "Node"
AddAttachment::$displayField = "title"
AddAttachment::$useDbConfig = "default"
AddAttachment::$useTable = "nodes"
AddAttachment::$id = false
AddAttachment::$data = array
AddAttachment::$table = "nodes"
AddAttachment::$primaryKey = "id"
AddAttachment::$_schema = array
AddAttachment::$validate = array
AddAttachment::$validationErrors = array
AddAttachment::$tablePrefix = ""
AddAttachment::$alias = "AddAttachment"
AddAttachment::$tableToModel = array
AddAttachment::$logTransactions = false
AddAttachment::$cacheQueries = false
AddAttachment::$belongsTo = array
AddAttachment::$hasOne = array
AddAttachment::$hasMany = array
AddAttachment::$hasAndBelongsToMany = array
AddAttachment::$Behaviors = BehaviorCollection object
AddAttachment::$whitelist = array
AddAttachment::$cacheSources = true
AddAttachment::$findQueryType = NULL
AddAttachment::$recursive = 1
AddAttachment::$order = NULL
AddAttachment::$virtualFields = array
AddAttachment::$__associationKeys = array
AddAttachment::$__associations = array
AddAttachment::$__backAssociation = array
AddAttachment::$__insertID = NULL
AddAttachment::$__numRows = NULL
AddAttachment::$__affectedRows = NULL
AddAttachment::$_findMethods = array

And I am not able to attach anything. Just for testing I tried to
change the file input form with simple title and body fields, and to
remove the Attachable behavior form the AddAttachment behavior

Sorry for the long post, trying to explain everything. Thanks to
anyone able to help

-- 
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


How do I process forms via Ajax for a Quiz-like game in CakePHP?

2011-08-08 Thread ujjain
I have written a game in PHP, but I am planning to rewrite it OOP and
with CakePHP. Starting it was pretty easy and it seems I wasted a lot
of productivity in having written all the queries myself etc. I spent
almost 20 hours (wasted much though), while with Cake it could've been
done in a few hours.

This leaves me more time for making the game smoother and better. I
was using simple forms in the game in PHP, but I would like to do it
better this time.

I see so much helpers in Cakephp and am not sure what to use. The game
is for a my personal language learning site and is like Rosetta Stone.
Users should click on 1 of the 4 images when they see a text like
"perro (Spanish)".

What would be the best way to implement this? I was thinking about
xmlHttprequest forms that use Javascript. Jquery, Ajax, or prototype.

I am however embarrassed to say that after having had multiple sites
and have always heard people say Javascript is easy, never having
programmed any Javascript and don't find it easy-looking at all
compared to PHP. Can somebody point me in the right direction? It just
seems that I shouldn't be using POST-forms here. What should I use to
optimize user experience?

-- 
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: The better way to create many register forms for many types of users?

2011-07-05 Thread Vulinux
Hi castarco,

Just to get this straight --> You got one User Model, that will be
build for every registered user. One User then belongs to either one
Student or one Company?

There are probably a lot of better attempts at doing this, but I would
do the following:
Build a method in your User Model, that is invoked in your after save
callback to either build a Student or Company Object and transfer the
id of your User to the invoked one.
The register method then would be implemented in your User Controller.

To display different register forms, you could load different elements
for each of your specialized User.

Kind regards,
Vulinus

On 5 Jul., 11:13, castarco  wrote:
> Hello,
>
> I'm programming an application that have many types of users (such as
> Students and Companies), the case is that the register forms should be
> different for the different types of users...
>
> I have the Users, Students and Companies controllers... and my
> question is, wich is the better place to create a register method? In
> the User controller, or in the more speciallized Students and
> Companies Controllers? (there is no inheritance, I'm using Acl to
> stablish group permissions).
>
> Thanks in advance.

-- 
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


The better way to create many register forms for many types of users?

2011-07-05 Thread castarco
Hello,

I'm programming an application that have many types of users (such as
Students and Companies), the case is that the register forms should be
different for the different types of users...

I have the Users, Students and Companies controllers... and my
question is, wich is the better place to create a register method? In
the User controller, or in the more speciallized Students and
Companies Controllers? (there is no inheritance, I'm using Acl to
stablish group permissions).

Thanks in advance.

-- 
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


What's the best way to change select box option labels when using Automagic forms?

2011-06-02 Thread Seth Meranda
I have a standard baked controller with add and edits for a list of
students. Each student belongs to one family, so I have this in my
Student Model:

var $belongsTo = array('Family' => array(
'className' => 'Family',
'foreignKey' => 'family_id')
);

In my student view, the Family select box (echo $this->Form-
>select('family_id');) only shows the family_id (INT) as both the
value and the label. What I'd like to do is instead, keep the value as
the family_id, but the label should be last_name, first_name. So I
wrote this in my students_controller (not sure if it's the best
approach):
$families = $this->Student->Family->find(
'all',
array(
'fields' => array(
'last_name',
'first_name'
),
'order' => array(
'Family.last_name ASC'
)
)
);
foreach($families as $row)
{
$families_list["{$row['Family']['id']}"] = "{$row['Family']
['last_name']}, {$row['Family']['first_name']}";
}
$this->set('families_list', $families_list);

Then in the view:

echo $this->Form->select('family_id', $families_list);

This works for my add view, but for my edit view, the select box is
empty.

Any ideas on how to get this to work for my edit view while still
maintaining the selected value?

-- 
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: Problem with bools and forms

2011-05-09 Thread Ernesto
Hi Tilen, thanks for your effort.
Sadly your solution doesn't work

i ended up modifying dbo_source's function "boolean" from

public function boolean($data, $quote = false) {
if ($quote) {
return !empty($data) ? '1' : '0';
}
return !empty($data);
}

to

public function boolean($data, $quote = false) {
return !empty($data) ? '1' : '0';
}

Any dev can confirm this modify wouldn't break anything? :D

On 9 Mag, 15:34, Tilen Majerle  wrote:
> check thishttp://book.cakephp.org/view/1402/options-default
>
> and 
> thishttp://book.cakephp.org/view/1405/options-empty
> --
> Lep pozdrav, Tilen Majerlehttp://majerle.eu
>
> 2011/5/9 Ernesto 
>
>
>
> > Hello.
>
> > when the bool field is FALSE Cake reads that value as "" (empty
> > value).
>
> > this is causing some troubles in my newest app, where due to
> > customer's habits i'm using boolean selects (simple select boxes with
> > "Yes" ans "No" options) instead of checkboxes.
>
> > my select boxes' options are defined this way:
> > array(0 => "No", 1 => "Yes")
>
> > is there any way to change the default false boolean value to
> > "0" (zero) ??
>
> > --
> > Our newest site for the community: CakePHP Video Tutorials
> >http://tv.cakephp.org
> > Check out the new CakePHP Questions sitehttp://ask.cakephp.organd 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
> > athttp://groups.google.com/group/cake-php

-- 
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: Problem with bools and forms

2011-05-09 Thread Tilen Majerle
check this
http://book.cakephp.org/view/1402/options-default

and this
http://book.cakephp.org/view/1405/options-empty
--
Lep pozdrav, Tilen Majerle
http://majerle.eu



2011/5/9 Ernesto 

> Hello.
>
> when the bool field is FALSE Cake reads that value as "" (empty
> value).
>
> this is causing some troubles in my newest app, where due to
> customer's habits i'm using boolean selects (simple select boxes with
> "Yes" ans "No" options) instead of checkboxes.
>
> my select boxes' options are defined this way:
> array(0 => "No", 1 => "Yes")
>
> is there any way to change the default false boolean value to
> "0" (zero) ??
>
> --
> 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
>

-- 
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


Problem with bools and forms

2011-05-09 Thread Ernesto
Hello.

when the bool field is FALSE Cake reads that value as "" (empty
value).

this is causing some troubles in my newest app, where due to
customer's habits i'm using boolean selects (simple select boxes with
"Yes" ans "No" options) instead of checkboxes.

my select boxes' options are defined this way:
array(0 => "No", 1 => "Yes")

is there any way to change the default false boolean value to
"0" (zero) ??

-- 
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: User/Admin definable forms (schemaless forms)

2011-04-04 Thread gremlin
Look into EAV structures. Basically you build tables that map data
types (field types) to their values and the owning model by name and
id. A polymorphic behavior would do most of the work. There are a few
of on github that google finds pretty easily.

This of course doesn't do the form building work, or decide how to map
value types to input types etc. But it should give you something to
play with.
http://debuggable.com/posts/unlimited-model-fields-expandable-behavior:48428c2e-9a88-47ec-ae8e-77a64834cda3

On Apr 4, 7:52 pm, Greg Skerman  wrote:
> Hi,
>
> I'm currently toying with the idea of a user definable form. This would
> allow a site administrator to create new forms to capture various data, and
> report on the data in the admin section.
>
> I've got the basic data structure, being a forms table, having many
> form_fields, each having one form_field_type, and storing information into
> form_field_responses
>
> There are 2 approaches I'm playing with to do this.
>
> Approach 1 would be a simple helper which can be used to autogenerate the
> form. This would require the data for the form structure to be passed to the
> view in each method.
>
> Approach 2 is to use a behavior with a generateForm method that overwrites
> $_schema (based on form_fields and form_field_type) to facilitate auto-form
> generation leveraging the form helper's inputs() method.
>
> anyone got any thoughts on the best approach for this sort of thing?

-- 
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


User/Admin definable forms (schemaless forms)

2011-04-04 Thread Greg Skerman
Hi,

I'm currently toying with the idea of a user definable form. This would
allow a site administrator to create new forms to capture various data, and
report on the data in the admin section.

I've got the basic data structure, being a forms table, having many
form_fields, each having one form_field_type, and storing information into
form_field_responses

There are 2 approaches I'm playing with to do this.

Approach 1 would be a simple helper which can be used to autogenerate the
form. This would require the data for the form structure to be passed to the
view in each method.

Approach 2 is to use a behavior with a generateForm method that overwrites
$_schema (based on form_fields and form_field_type) to facilitate auto-form
generation leveraging the form helper's inputs() method.

anyone got any thoughts on the best approach for this sort of thing?

-- 
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: Building spell check into forms

2011-03-11 Thread Dr. Tarique Sani
On Fri, Mar 11, 2011 at 5:21 PM, euromark wrote:

> nice link - I like the afterthedeadline-style
> almost better and more powerful as google I would assume
> and it seems to come with a jquery plugin :)
>


Yes jquery plugin and integration with several WYSIWYG editors

FWIW there are also browser extensions and wordpress plugins available for
the same

Cheers
Tarique



>
> On 11 Mrz., 09:28, chris  wrote:
> > Thanks for the suggestion, I will take a look into it.
> >
>

-- 
=
PHP for E-Biz: http://sanisoft.com
=

-- 
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: Building spell check into forms

2011-03-11 Thread euromark
nice link - I like the afterthedeadline-style
almost better and more powerful as google I would assume
and it seems to come with a jquery plugin :)


On 11 Mrz., 09:28, chris  wrote:
> Thanks for the suggestion, I will take a look into it.
>
> In regards to the previous post about why I would bother. The client
> I'm producing the website for has requested the functionality. The
> website will be public facing and could be viewed on a variety of OS/
> Browser platforms, so I can't rely on the fact that modern browsers
> have it built in.
>
> On Mar 11, 3:20 am, "Dr. Tarique Sani"  wrote:
>
>
>
>
>
>
>
> > Check outhttp://www.afterthedeadline.com/
>
> > HTH
> > Tarique
>
> > On Thu, Mar 10, 2011 at 10:14 PM, chris 
> > wrote:
>
> > > I realise that this isn't stictly a cakePHP question. But as I'm
> > > building my application in cakePHP, I just wanted to see if anyone had
> > > any advice in the area.
>
> > > I have a requirement to provide a spell check functionality in some of
> > > my forms. The input fields are simple 'textarea' fields.
>
> > > Looking around, there seems to be a number of solutions. Most, if not
> > > all, seem to be javascript front ends, with a php file that is called
> > > to do the spellchecking.
>
> > > The few I've looked at include
>
> > >http://code.google.com/p/jquery-spellchecker/
> > >http://www.phpspellcheck.com/
>
> > > I've tried the first one and can't get the demo code to work once
> > > downloaded, the second one the demo works fine, but I havn't gone
> > > further than this.
>
> > > Anyway, what I'd like to know is. Does anyone have expereince of
> > > adding a spell checker to their cakePHP application? And if so, are
> > > there any recommendations of which to use?
>
> > > Thanks
>
> > > --
> > > Our newest site for the community: CakePHP Video Tutorials
> > >http://tv.cakephp.org
> > > Check out the new CakePHP Questions sitehttp://ask.cakephp.organdhelp
> > > 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
> > > athttp://groups.google.com/group/cake-php
>
> > --
> > =
> > PHP for E-Biz:http://sanisoft.com
> > =

-- 
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: Building spell check into forms

2011-03-11 Thread chris
Thanks for the suggestion, I will take a look into it.

In regards to the previous post about why I would bother. The client
I'm producing the website for has requested the functionality. The
website will be public facing and could be viewed on a variety of OS/
Browser platforms, so I can't rely on the fact that modern browsers
have it built in.

On Mar 11, 3:20 am, "Dr. Tarique Sani"  wrote:
> Check outhttp://www.afterthedeadline.com/
>
> HTH
> Tarique
>
> On Thu, Mar 10, 2011 at 10:14 PM, chris 
> wrote:
>
>
>
> > I realise that this isn't stictly a cakePHP question. But as I'm
> > building my application in cakePHP, I just wanted to see if anyone had
> > any advice in the area.
>
> > I have a requirement to provide a spell check functionality in some of
> > my forms. The input fields are simple 'textarea' fields.
>
> > Looking around, there seems to be a number of solutions. Most, if not
> > all, seem to be javascript front ends, with a php file that is called
> > to do the spellchecking.
>
> > The few I've looked at include
>
> >http://code.google.com/p/jquery-spellchecker/
> >http://www.phpspellcheck.com/
>
> > I've tried the first one and can't get the demo code to work once
> > downloaded, the second one the demo works fine, but I havn't gone
> > further than this.
>
> > Anyway, what I'd like to know is. Does anyone have expereince of
> > adding a spell checker to their cakePHP application? And if so, are
> > there any recommendations of which to use?
>
> > Thanks
>
> > --
> > Our newest site for the community: CakePHP Video Tutorials
> >http://tv.cakephp.org
> > Check out the new CakePHP Questions sitehttp://ask.cakephp.organd 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
> > athttp://groups.google.com/group/cake-php
>
> --
> =
> PHP for E-Biz:http://sanisoft.com
> =

-- 
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: Building spell check into forms

2011-03-10 Thread Dr. Tarique Sani
Check out http://www.afterthedeadline.com/

HTH
Tarique

On Thu, Mar 10, 2011 at 10:14 PM, chris wrote:

> I realise that this isn't stictly a cakePHP question. But as I'm
> building my application in cakePHP, I just wanted to see if anyone had
> any advice in the area.
>
> I have a requirement to provide a spell check functionality in some of
> my forms. The input fields are simple 'textarea' fields.
>
> Looking around, there seems to be a number of solutions. Most, if not
> all, seem to be javascript front ends, with a php file that is called
> to do the spellchecking.
>
> The few I've looked at include
>
> http://code.google.com/p/jquery-spellchecker/
> http://www.phpspellcheck.com/
>
> I've tried the first one and can't get the demo code to work once
> downloaded, the second one the demo works fine, but I havn't gone
> further than this.
>
> Anyway, what I'd like to know is. Does anyone have expereince of
> adding a spell checker to their cakePHP application? And if so, are
> there any recommendations of which to use?
>
> Thanks
>
> --
> 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
>



-- 
=
PHP for E-Biz: http://sanisoft.com
=

-- 
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: Building spell check into forms

2011-03-10 Thread Ryan Schmidt

On Mar 10, 2011, at 10:44, chris wrote:

> I have a requirement to provide a spell check functionality in some of
> my forms.

Meh. Does anybody actually want that? Why not just use a browser or operating 
system that already provides spell check on the client side? (e.g. Mac OS X has 
system-wide spell check)



-- 
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


Building spell check into forms

2011-03-10 Thread chris
I realise that this isn't stictly a cakePHP question. But as I'm
building my application in cakePHP, I just wanted to see if anyone had
any advice in the area.

I have a requirement to provide a spell check functionality in some of
my forms. The input fields are simple 'textarea' fields.

Looking around, there seems to be a number of solutions. Most, if not
all, seem to be javascript front ends, with a php file that is called
to do the spellchecking.

The few I've looked at include

http://code.google.com/p/jquery-spellchecker/
http://www.phpspellcheck.com/

I've tried the first one and can't get the demo code to work once
downloaded, the second one the demo works fine, but I havn't gone
further than this.

Anyway, what I'd like to know is. Does anyone have expereince of
adding a spell checker to their cakePHP application? And if so, are
there any recommendations of which to use?

Thanks

-- 
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


Forms, Polls and others..

2011-02-28 Thread Miloš Vučinić
Hi,

I am working on a project where I need to make polls and surveys on
the web site. Those should be very similar to google spread sheet, but
it has to work from my web site.

Does anyone know if there are components for form generation or
something similar to that, or is there a propper way to start.. ?

All the best
Milos Vucinic

-- 
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: evalScripts and AJAX forms

2011-01-25 Thread cricket
On Tue, Jan 25, 2011 at 5:17 AM, Rory  wrote:
>
> I can't remember if JS has always come back in CDATA tags because like
> I said, it was working at one point, which would indicate JS wasn't
> coming back within CDATA tags.

If you can't remember whether it was wrapped in CDATA, the fact that
it's not now working does not indicate that CDATA has anything to do
with it.

>> I've used the Web Inspector tool in Safari to inspect the HTML view
>> being returned by the $ajax->link and the appropriate JavaScript is
>> there, however when loaded into the page, the JavaScript is stripped.
>> I thought it may be something to do with prototype's evalScripts
>> stripping the JavaScript from the returned view, however even when I
>> turn it off, the JavaScript isn't included.

Setting it to false will guarantee that it will not work.

I gave up on Prototype a long time ago, so I'm not sure what to
suggest. But, evalScripts is an option for Ajax.Updater. There's also
a more general Ajax option, evalJS:
http://www.prototypejs.org/api/ajax/options

Can you see which Content-type header is being returned?

Without seeing any code, though, it's difficult to suggest anything else.

-- 
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: evalScripts and AJAX forms

2011-01-25 Thread Rory
Okay, I think I've found out why it isn't working - the Javascript in
the Ajax response is coming through surrounded in CDATA tags, which is
why it's getting stripped.

I can't remember if JS has always come back in CDATA tags because like
I said, it was working at one point, which would indicate JS wasn't
coming back within CDATA tags.

R

On Jan 24, 11:58 am, Rory  wrote:
> I've recently stumbled across a major problem which has brought the
> development of my application to a complete stand still.
>
> Basically, the way the application has been working up until now, is a
> view would be loaded into a div tag via AJAX. This view would contain
> an AJAX form which when submitted updates a status div with the
> returned AJAX content. This was working fine until a few days ago when
> it just simply stopped working.
>
> The views still load via AJAX ($ajax->link) but the submission of the
> forms via AJAX does not work.
>
> I've used the Web Inspector tool in Safari to inspect the HTML view
> being returned by the $ajax->link and the appropriate JavaScript is
> there, however when loaded into the page, the JavaScript is stripped.
> I thought it may be something to do with prototype's evalScripts
> stripping the JavaScript from the returned view, however even when I
> turn it off, the JavaScript isn't included.
>
> The strangest part of the whole puzzle is that I've literally done
> nothing that I can think of that would universally stop all forms from
> working. I could understand if it wasn't working for a single form -
> but not all of them simultaneously.
>
> Anyone got any ideas, because I'm totally stumped.
>
> Thanks,
> Rory

-- 
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


evalScripts and AJAX forms

2011-01-24 Thread Rory
I've recently stumbled across a major problem which has brought the
development of my application to a complete stand still.

Basically, the way the application has been working up until now, is a
view would be loaded into a div tag via AJAX. This view would contain
an AJAX form which when submitted updates a status div with the
returned AJAX content. This was working fine until a few days ago when
it just simply stopped working.

The views still load via AJAX ($ajax->link) but the submission of the
forms via AJAX does not work.

I've used the Web Inspector tool in Safari to inspect the HTML view
being returned by the $ajax->link and the appropriate JavaScript is
there, however when loaded into the page, the JavaScript is stripped.
I thought it may be something to do with prototype's evalScripts
stripping the JavaScript from the returned view, however even when I
turn it off, the JavaScript isn't included.

The strangest part of the whole puzzle is that I've literally done
nothing that I can think of that would universally stop all forms from
working. I could understand if it wasn't working for a single form -
but not all of them simultaneously.

Anyone got any ideas, because I'm totally stumped.

Thanks,
Rory

-- 
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: Dynamic forms

2010-12-20 Thread cricket
2010/12/20 Andrés Manikis :
>
> I do need different fields for passport and National document. For
> example, the passport has an expiration date whereas the national
> document has not. So I think I should extend the Credential model.
> How could I do that? I know how to do it at the PHP side but I don't
> know how I should create the tables for that to work.

Extending might not be necessary. See below.

> Let's say I require the following:
> For passport: An alphanumeric code and an expiration date.
> For national document: A numeric code, no letters.
> I would like to be able to change the available view fields at
> runtime. For example, if I check the checkbox, the passport fields
> would appear and the national document fields dissapear.
> I could do it with JQuery or maybe with multipage forms, but the
> latter is another problem, isn't it?

You could do it with radio buttons. They needn't be created with
FormHelper (in fact, it'd be simpler to do it manually). Add a
listener with JQuery to hide/show the appropriate fields for
Passport/NationalDocument depending on the radio button selected.
Then, when the form submits, remove the hidden field altogether. You
could then create validation rules in the Person model to ensure that
only one was included in the submitted data before saving. You can
access eg. $this->data['Passport'] from within your custom validation
method. Then you could have rules in both Passport and
NationalDocument to handle validation for their respective values.

Actually, because you may have more than one field required for
Passport, instead of hiding/showing form elements, you could put them
in their model-specific fieldsets. Give both of them IDs and hide/show
the fieldsets. Again, before the form submits, remove the entire
hidden fieldset from the DOM.


Form['Passport']['code'];
echo $this->Form['Passport']['expiration'];
?>




> Apart from that, when you say, "create the association array" what do
> you mean?

Sorry, that wasn't very clear. I meant that you could update
$this->data with whatever values you needed, depending on which was
chosen. But that shouldn't be necessary if you go the route I
suggested above.

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

You received this message because you are subscribed to the Google Groups 
"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: Dynamic forms

2010-12-20 Thread Andrés Manikis


On 18 dic, 16:46, cricket  wrote:
> On Fri, Dec 17, 2010 at 11:20 PM, Andr?s Manikis
>
>  wrote:
> > Hello.
> > I have the following questions.
>
> > Let's suppose I have, say, a person model which has an id, a name and a
> > boolean that tells whether this person is native from a specific country or
> > not (for example, native from Argentina or not).
>
> > In the case of being native, he has a national document, otherwise, he has a
> > passport.
>
> > So, the first question: is ok to have a person model that has one passport
> > or one national document? Maybe I should make this person to have one
> > generic document which then can be a passport or a national document.
>
> You do either. That is, a model can have a $hasOne association that is
> empty. Your data from a find() would just return an empty array for
> Passport or NationalDocument (whichever didn't exist). But, if the
> model can only have one or the other, it might be simplest to create a
> more general model, eg. Credential. That model could either be
> extended by Passport and NationalDocument, or it could be associated
> with a CredentialType model whose table was a list of types. It really
> depends on whether you need other firleds for Passport and
> NationalDocument.
>
I do need different fields for passport and National document. For
example, the passport has an expiration date whereas the national
document has not. So I think I should extend the Credential model.
How could I do that? I know how to do it at the PHP side but I don't
know how I should create the tables for that to work.

> > The second question would be: how can I change the form fields dynamically
> > in the view depending of the person being native or foreign? I mean, if the
> > person is native, the "add person" form should have a "national document"
> > field present whereas if the person is foreign, the field present should be
> > "passport" instead of "national document".
>
> What information do you require in either case? If it's only, eg. a
> number, you could use a single field in conjunction with a checkbox,
> neither of which directly corresponds to an actual Person field. In
> beforeValidate, look at the checkbox value and create the association
> array according to it. Then assign to it the text element value. Can't
> really suggest much more without knowing what the information is that
> you require, though.
Let's say I require the following:
For passport: An alphanumeric code and an expiration date.
For national document: A numeric code, no letters.
I would like to be able to change the available view fields at
runtime. For example, if I check the checkbox, the passport fields
would appear and the national document fields dissapear.
I could do it with JQuery or maybe with multipage forms, but the
latter is another problem, isn't it?
Apart from that, when you say, "create the association array" what do
you mean?

Thank you very much for your help.
Andrés

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: Dynamic forms

2010-12-18 Thread cricket
On Fri, Dec 17, 2010 at 11:20 PM, Andr?s Manikis
 wrote:
> Hello.
> I have the following questions.
>
> Let's suppose I have, say, a person model which has an id, a name and a
> boolean that tells whether this person is native from a specific country or
> not (for example, native from Argentina or not).
>
> In the case of being native, he has a national document, otherwise, he has a
> passport.
>
> So, the first question: is ok to have a person model that has one passport
> or one national document? Maybe I should make this person to have one
> generic document which then can be a passport or a national document.

You do either. That is, a model can have a $hasOne association that is
empty. Your data from a find() would just return an empty array for
Passport or NationalDocument (whichever didn't exist). But, if the
model can only have one or the other, it might be simplest to create a
more general model, eg. Credential. That model could either be
extended by Passport and NationalDocument, or it could be associated
with a CredentialType model whose table was a list of types. It really
depends on whether you need other firleds for Passport and
NationalDocument.


> The second question would be: how can I change the form fields dynamically
> in the view depending of the person being native or foreign? I mean, if the
> person is native, the "add person" form should have a "national document"
> field present whereas if the person is foreign, the field present should be
> "passport" instead of "national document".

What information do you require in either case? If it's only, eg. a
number, you could use a single field in conjunction with a checkbox,
neither of which directly corresponds to an actual Person field. In
beforeValidate, look at the checkbox value and create the association
array according to it. Then assign to it the text element value. Can't
really suggest much more without knowing what the information is that
you require, though.

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


Dynamic forms

2010-12-18 Thread Andr?s Manikis
Hello.
I have the following questions.

Let's suppose I have, say, a person model which has an id, a name and a 
boolean that tells whether this person is native from a specific country or 
not (for example, native from Argentina or not).

In the case of being native, he has a national document, otherwise, he has a 
passport.

So, the first question: is ok to have a person model that has one passport 
or one national document? Maybe I should make this person to have one 
generic document which then can be a passport or a national document.

The second question would be: how can I change the form fields dynamically 
in the view depending of the person being native or foreign? I mean, if the 
person is native, the "add person" form should have a "national document" 
field present whereas if the person is foreign, the field present should be 
"passport" instead of "national document".

Hope I made myself clear. If not, please tell me where I'm not being so.
It's very important for me to discuss this as I'm working on a project which 
model is very dependant on the nationality of the people.

Thank you very much.
Andrés

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: possible to create a nested post with forms?

2010-12-16 Thread Shinya Koizumi
Looks like if I use the name with index like 'category.0.subcategory' but
I can't get consistent result. 

Is there any limitation of how deep I can go?

I am using 1.2.8

Shinya

-Original Message-
From: cake-php@googlegroups.com [mailto:cake-...@googlegroups.com] On Behalf
Of cake-learner
Sent: Wednesday, December 15, 2010 10:54 PM
To: CakePHP
Subject: possible to create a nested post with forms?

I am trying create a form so that when post that data this will still
keep the relationships with other element.
Say i have a category name and a subcategory name like shown in below.
How can i define the form so that the relationship between this
category and subcategory will be kept when submitted?

Category 1
-subcategory 1
Categ 2
-subcategory 1
-sbucategory 2

and this form is submited

Array{
   Category => Array{
  name => 'Category 1'
  subcategory => Array{
   'name' =>
'subcategory'
}
}

 input( 'Category.name', array( 'name' =>
'Category.name[]', 'label' => '', 'class' => 'category_title' ) ); ?>

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

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


possible to create a nested post with forms?

2010-12-15 Thread cake-learner
I am trying create a form so that when post that data this will still
keep the relationships with other element.
Say i have a category name and a subcategory name like shown in below.
How can i define the form so that the relationship between this
category and subcategory will be kept when submitted?

Category 1
-subcategory 1
Categ 2
-subcategory 1
-sbucategory 2

and this form is submited

Array{
   Category => Array{
  name => 'Category 1'
  subcategory => Array{
   'name' =>
'subcategory'
}
}

 input( 'Category.name', array( 'name' =>
'Category.name[]', 'label' => '', 'class' => 'category_title' ) ); ?>

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: Two Forms for the Same Model with two datasets

2010-12-08 Thread cricket
On Tue, Dec 7, 2010 at 5:45 PM, Gerrit  wrote:
> Hello everybody,
>
> I want to create an Order Form with Order positions. If i want to use
> two Order positions (this IS a Model) on one page, how i will Be able
> to do this? With "1.OrderPosition.Count" or "OrderPosition.1.Count"?

If they're two separate forms you shouldn't need to do anything
special. If you want to save multiple records from the same form
you'll be using saveAll(). See this link for a good writeup on that:

http://nuts-and-bolts-of-cakephp.com/2008/08/01/practical-use-of-saveall-part-1-working-with-multiple-models/

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: Two Forms for the Same Model with two datasets

2010-12-08 Thread NoEvidenZ
> I want to create an Order Form with Order positions. If i want to use
> two Order positions (this IS a Model) on one page, how i will Be able
> to do this? With "1.OrderPosition.Count" or "OrderPosition.1.Count"?

I'm sorry, I can't really follow the question. Can you give us a bit
more information about the purpose of the Order Positions and how they
relate to an Order, or how you need them displayed?

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


Two Forms for the Same Model with two datasets

2010-12-07 Thread Gerrit
Hello everybody,

I want to create an Order Form with Order positions. If i want to use
two Order positions (this IS a Model) on one page, how i will Be able
to do this? With "1.OrderPosition.Count" or "OrderPosition.1.Count"?

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: Forms security: Not displaying input means it is protected? --zivi-muh

2010-11-29 Thread Joshua Muheim
Thanks, guys!

On Fri, Nov 26, 2010 at 4:44 PM, euromark  wrote:
> some additional infos:
> http://www.dereuromark.de/2010/10/05/cakephp-security/
>
> On 26 Nov., 14:32, odd  wrote:
>> That's how it is. Personally i'm additionally using the fieldList
>> feature (which unfortunately doesn't work well with multiple models
>> and saveAll) as a last line of defense in case something goes wrong
>> and a modified request slips through.
>>
>> Regards
>>
>> Joshua Muheim schrieb:
>>
>>
>>
>>
>>
>>
>>
>> > Thanks for the hint to the $whitelist, Stephen. But this seems not
>> > necessary to me anymore when using the Security component (which I do
>> > and I forgot to mention in my first post). Look at this
>> > (http://book.cakephp.org/view/175/Security-Component):
>>
>> > "When using the Security Component you must use the FormHelper to
>> > create your forms. The Security Component looks for certain indicators
>> > that are created and managed by the FormHelper (especially those
>> > created in create() and end()). Dynamically altering the fields that
>> > are submitted in a POST request (e.g. disabling, deleting or creating
>> > new fields via JavaScript) is likely to trigger a black-holing of the
>> > request. See the $validatePost or $disabledFields configuration
>> > parameters."
>>
>> > So if you're using Security component, the end user can't mess with
>> > the POST data anymore. :-)
>>
>> > Any other comment about this, anyone?
>>
>> > On Fri, Nov 26, 2010 at 12:08 PM, Stephen
>> >  wrote:
>> > > Hi There
>>
>> > > You should use a whitelist to specify the fields to save, any other 
>> > > fields
>> > > will not be saved.
>>
>> > > Even if you don't display the field on the page, a user can still create 
>> > > the
>> > > post variable from within their browser and use it to change data they
>> > > shouldn't really be allowed to.
>>
>> > > Hope this helps
>>
>> > > Stephen
>>
>> > > On 26 November 2010 10:38, psybear83  wrote:
>>
>> > >> Hey everybody
>>
>> > >> In my application, users can edit their email, phone number etc., but
>> > >> they are *not* allowed to edit their username - only admins are
>> > >> allowed to do that.
>>
>> > >> So I'm wondering: is it safe to simply not display the username field
>> > >> to the user? Afaik CakePHP makes sure that the form hasn't been
>> > >> manually edited (e.g. adding a username input field), right? So I
>> > >> don't have to double-check on the application's side, e.g. by
>> > >> unsetting the $data[User][username] field, as long as I'm only
>> > >> displaying form fields using CakePHP's form helper (and not
>> > >> "deactivating" them by just hiding them using CSS or so), right?
>>
>> > >> If so - yeah, sweet! Thanks, CakePHP! :-)
>>
>> > >> Waiting for your confirmation about this fact, guys... Thanks!
>>
>> > >> Check out the new CakePHP Questions sitehttp://cakeqs.organd 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
>> > >> athttp://groups.google.com/group/cake-php?hl=en
>>
>> > > --
>> > > Kind Regards
>> > >  Stephen @ NinjaCoderMonkey
>>
>> > >  www.ninjacodermonkey.co.uk
>>
>> > > Check out the new CakePHP Questions sitehttp://cakeqs.organd 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
>
> 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
>

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: Forms security: Not displaying input means it is protected? --zivi-muh

2010-11-26 Thread euromark
some additional infos:
http://www.dereuromark.de/2010/10/05/cakephp-security/

On 26 Nov., 14:32, odd  wrote:
> That's how it is. Personally i'm additionally using the fieldList
> feature (which unfortunately doesn't work well with multiple models
> and saveAll) as a last line of defense in case something goes wrong
> and a modified request slips through.
>
> Regards
>
> Joshua Muheim schrieb:
>
>
>
>
>
>
>
> > Thanks for the hint to the $whitelist, Stephen. But this seems not
> > necessary to me anymore when using the Security component (which I do
> > and I forgot to mention in my first post). Look at this
> > (http://book.cakephp.org/view/175/Security-Component):
>
> > "When using the Security Component you must use the FormHelper to
> > create your forms. The Security Component looks for certain indicators
> > that are created and managed by the FormHelper (especially those
> > created in create() and end()). Dynamically altering the fields that
> > are submitted in a POST request (e.g. disabling, deleting or creating
> > new fields via JavaScript) is likely to trigger a black-holing of the
> > request. See the $validatePost or $disabledFields configuration
> > parameters."
>
> > So if you're using Security component, the end user can't mess with
> > the POST data anymore. :-)
>
> > Any other comment about this, anyone?
>
> > On Fri, Nov 26, 2010 at 12:08 PM, Stephen
> >  wrote:
> > > Hi There
>
> > > You should use a whitelist to specify the fields to save, any other fields
> > > will not be saved.
>
> > > Even if you don't display the field on the page, a user can still create 
> > > the
> > > post variable from within their browser and use it to change data they
> > > shouldn't really be allowed to.
>
> > > Hope this helps
>
> > > Stephen
>
> > > On 26 November 2010 10:38, psybear83  wrote:
>
> > >> Hey everybody
>
> > >> In my application, users can edit their email, phone number etc., but
> > >> they are *not* allowed to edit their username - only admins are
> > >> allowed to do that.
>
> > >> So I'm wondering: is it safe to simply not display the username field
> > >> to the user? Afaik CakePHP makes sure that the form hasn't been
> > >> manually edited (e.g. adding a username input field), right? So I
> > >> don't have to double-check on the application's side, e.g. by
> > >> unsetting the $data[User][username] field, as long as I'm only
> > >> displaying form fields using CakePHP's form helper (and not
> > >> "deactivating" them by just hiding them using CSS or so), right?
>
> > >> If so - yeah, sweet! Thanks, CakePHP! :-)
>
> > >> Waiting for your confirmation about this fact, guys... Thanks!
>
> > >> Check out the new CakePHP Questions sitehttp://cakeqs.organd 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
> > >> athttp://groups.google.com/group/cake-php?hl=en
>
> > > --
> > > Kind Regards
> > >  Stephen @ NinjaCoderMonkey
>
> > >  www.ninjacodermonkey.co.uk
>
> > > Check out the new CakePHP Questions sitehttp://cakeqs.organd 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

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: Forms security: Not displaying input means it is protected? --zivi-muh

2010-11-26 Thread odd
That's how it is. Personally i'm additionally using the fieldList
feature (which unfortunately doesn't work well with multiple models
and saveAll) as a last line of defense in case something goes wrong
and a modified request slips through.

Regards


Joshua Muheim schrieb:
> Thanks for the hint to the $whitelist, Stephen. But this seems not
> necessary to me anymore when using the Security component (which I do
> and I forgot to mention in my first post). Look at this
> (http://book.cakephp.org/view/175/Security-Component):
>
> "When using the Security Component you must use the FormHelper to
> create your forms. The Security Component looks for certain indicators
> that are created and managed by the FormHelper (especially those
> created in create() and end()). Dynamically altering the fields that
> are submitted in a POST request (e.g. disabling, deleting or creating
> new fields via JavaScript) is likely to trigger a black-holing of the
> request. See the $validatePost or $disabledFields configuration
> parameters."
>
> So if you're using Security component, the end user can't mess with
> the POST data anymore. :-)
>
> Any other comment about this, anyone?
>
> On Fri, Nov 26, 2010 at 12:08 PM, Stephen
>  wrote:
> > Hi There
> >
> > You should use a whitelist to specify the fields to save, any other fields
> > will not be saved.
> >
> > Even if you don't display the field on the page, a user can still create the
> > post variable from within their browser and use it to change data they
> > shouldn't really be allowed to.
> >
> > Hope this helps
> >
> > Stephen
> >
> > On 26 November 2010 10:38, psybear83  wrote:
> >>
> >> Hey everybody
> >>
> >> In my application, users can edit their email, phone number etc., but
> >> they are *not* allowed to edit their username - only admins are
> >> allowed to do that.
> >>
> >> So I'm wondering: is it safe to simply not display the username field
> >> to the user? Afaik CakePHP makes sure that the form hasn't been
> >> manually edited (e.g. adding a username input field), right? So I
> >> don't have to double-check on the application's side, e.g. by
> >> unsetting the $data[User][username] field, as long as I'm only
> >> displaying form fields using CakePHP's form helper (and not
> >> "deactivating" them by just hiding them using CSS or so), right?
> >>
> >> If so - yeah, sweet! Thanks, CakePHP! :-)
> >>
> >> Waiting for your confirmation about this fact, guys... 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
> >
> >
> >
> > --
> > Kind Regards
> >  Stephen @ NinjaCoderMonkey
> >
> >  www.ninjacodermonkey.co.uk
> >
> >
> > Check out the new CakePHP Questions site http://cakeqs.org and help others
> > with their CakePHP related questions.
> >
> > You received this message because you are subscribed to the Google Groups
> > "CakePHP" group.
> > To post to this group, send email to cake-php@googlegroups.com
> > To unsubscribe from this group, send email to
> > cake-php+unsubscr...@googlegroups.com For more options, visit this group at
> > http://groups.google.com/group/cake-php?hl=en
> >

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

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


Re: Forms security: Not displaying input means it is protected? --zivi-muh

2010-11-26 Thread Stephen
Ah that would explain it, I did scan your email over 3 times to be sure I
wasn't misunderstanding!

I haven't used the security component in this way yet so I am afraid I can't
be of any further help

I will use this component soon however, thanks for reminding me of its
existence :)

Kind Regards

 Stephen

On 26 November 2010 12:09, Joshua Muheim  wrote:

> Thanks for the hint to the $whitelist, Stephen. But this seems not
> necessary to me anymore when using the Security component (which I do
> and I forgot to mention in my first post). Look at this
> (http://book.cakephp.org/view/175/Security-Component):
>
> "When using the Security Component you must use the FormHelper to
> create your forms. The Security Component looks for certain indicators
> that are created and managed by the FormHelper (especially those
> created in create() and end()). Dynamically altering the fields that
> are submitted in a POST request (e.g. disabling, deleting or creating
> new fields via JavaScript) is likely to trigger a black-holing of the
> request. See the $validatePost or $disabledFields configuration
> parameters."
>
> So if you're using Security component, the end user can't mess with
> the POST data anymore. :-)
>
> Any other comment about this, anyone?
>
> On Fri, Nov 26, 2010 at 12:08 PM, Stephen
>  wrote:
> > Hi There
> >
> > You should use a whitelist to specify the fields to save, any other
> fields
> > will not be saved.
> >
> > Even if you don't display the field on the page, a user can still create
> the
> > post variable from within their browser and use it to change data they
> > shouldn't really be allowed to.
> >
> > Hope this helps
> >
> > Stephen
> >
> > On 26 November 2010 10:38, psybear83  wrote:
> >>
> >> Hey everybody
> >>
> >> In my application, users can edit their email, phone number etc., but
> >> they are *not* allowed to edit their username - only admins are
> >> allowed to do that.
> >>
> >> So I'm wondering: is it safe to simply not display the username field
> >> to the user? Afaik CakePHP makes sure that the form hasn't been
> >> manually edited (e.g. adding a username input field), right? So I
> >> don't have to double-check on the application's side, e.g. by
> >> unsetting the $data[User][username] field, as long as I'm only
> >> displaying form fields using CakePHP's form helper (and not
> >> "deactivating" them by just hiding them using CSS or so), right?
> >>
> >> If so - yeah, sweet! Thanks, CakePHP! :-)
> >>
> >> Waiting for your confirmation about this fact, guys... 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.comFor
> >>  more options, visit this group
> >> at http://groups.google.com/group/cake-php?hl=en
> >
> >
> >
> > --
> > Kind Regards
> >  Stephen @ NinjaCoderMonkey
> >
> >  www.ninjacodermonkey.co.uk
> >
> >
> > Check out the new CakePHP Questions site http://cakeqs.org and help
> others
> > with their CakePHP related questions.
> >
> > You received this message because you are subscribed to the Google Groups
> > "CakePHP" group.
> > To post to this group, send email to cake-php@googlegroups.com
> > To unsubscribe from this group, send email to
> > cake-php+unsubscr...@googlegroups.comFor
> >  more options, visit this group at
> > http://groups.google.com/group/cake-php?hl=en
> >
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others
> with their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.comFor
>  more options, visit this group at
> http://groups.google.com/group/cake-php?hl=en
>



-- 
Kind Regards
 Stephen @ NinjaCoderMonkey

 www.ninjacodermonkey.co.uk

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

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


Re: Forms security: Not displaying input means it is protected? --zivi-muh

2010-11-26 Thread Joshua Muheim
Thanks for the hint to the $whitelist, Stephen. But this seems not
necessary to me anymore when using the Security component (which I do
and I forgot to mention in my first post). Look at this
(http://book.cakephp.org/view/175/Security-Component):

"When using the Security Component you must use the FormHelper to
create your forms. The Security Component looks for certain indicators
that are created and managed by the FormHelper (especially those
created in create() and end()). Dynamically altering the fields that
are submitted in a POST request (e.g. disabling, deleting or creating
new fields via JavaScript) is likely to trigger a black-holing of the
request. See the $validatePost or $disabledFields configuration
parameters."

So if you're using Security component, the end user can't mess with
the POST data anymore. :-)

Any other comment about this, anyone?

On Fri, Nov 26, 2010 at 12:08 PM, Stephen
 wrote:
> Hi There
>
> You should use a whitelist to specify the fields to save, any other fields
> will not be saved.
>
> Even if you don't display the field on the page, a user can still create the
> post variable from within their browser and use it to change data they
> shouldn't really be allowed to.
>
> Hope this helps
>
> Stephen
>
> On 26 November 2010 10:38, psybear83  wrote:
>>
>> Hey everybody
>>
>> In my application, users can edit their email, phone number etc., but
>> they are *not* allowed to edit their username - only admins are
>> allowed to do that.
>>
>> So I'm wondering: is it safe to simply not display the username field
>> to the user? Afaik CakePHP makes sure that the form hasn't been
>> manually edited (e.g. adding a username input field), right? So I
>> don't have to double-check on the application's side, e.g. by
>> unsetting the $data[User][username] field, as long as I'm only
>> displaying form fields using CakePHP's form helper (and not
>> "deactivating" them by just hiding them using CSS or so), right?
>>
>> If so - yeah, sweet! Thanks, CakePHP! :-)
>>
>> Waiting for your confirmation about this fact, guys... 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
>
>
>
> --
> Kind Regards
>  Stephen @ NinjaCoderMonkey
>
>  www.ninjacodermonkey.co.uk
>
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others
> with their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at
> http://groups.google.com/group/cake-php?hl=en
>

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

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


Re: Forms security: Not displaying input means it is protected? --zivi-muh

2010-11-26 Thread Stephen
Hi There

You should use a whitelist to specify the fields to save, any other fields
will not be saved.

Even if you don't display the field on the page, a user can still create the
post variable from within their browser and use it to change data they
shouldn't really be allowed to.

Hope this helps

Stephen

On 26 November 2010 10:38, psybear83  wrote:

> Hey everybody
>
> In my application, users can edit their email, phone number etc., but
> they are *not* allowed to edit their username - only admins are
> allowed to do that.
>
> So I'm wondering: is it safe to simply not display the username field
> to the user? Afaik CakePHP makes sure that the form hasn't been
> manually edited (e.g. adding a username input field), right? So I
> don't have to double-check on the application's side, e.g. by
> unsetting the $data[User][username] field, as long as I'm only
> displaying form fields using CakePHP's form helper (and not
> "deactivating" them by just hiding them using CSS or so), right?
>
> If so - yeah, sweet! Thanks, CakePHP! :-)
>
> Waiting for your confirmation about this fact, guys... 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.comFor
>  more options, visit this group at
> http://groups.google.com/group/cake-php?hl=en
>



-- 
Kind Regards
 Stephen @ NinjaCoderMonkey

 www.ninjacodermonkey.co.uk

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

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


Forms security: Not displaying input means it is protected? --zivi-muh

2010-11-26 Thread psybear83
Hey everybody

In my application, users can edit their email, phone number etc., but
they are *not* allowed to edit their username - only admins are
allowed to do that.

So I'm wondering: is it safe to simply not display the username field
to the user? Afaik CakePHP makes sure that the form hasn't been
manually edited (e.g. adding a username input field), right? So I
don't have to double-check on the application's side, e.g. by
unsetting the $data[User][username] field, as long as I'm only
displaying form fields using CakePHP's form helper (and not
"deactivating" them by just hiding them using CSS or so), right?

If so - yeah, sweet! Thanks, CakePHP! :-)

Waiting for your confirmation about this fact, guys... 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: Making Forms using Loops for Populating Multiple Database Entries

2010-11-14 Thread Rameez
Hey I was looking around in the cake folder and opened to model class
to look at how save was working, found this lying in the create()
function there

$this->id = false;

seems to have done the trick, it. Thanks for your help, I am trying to
resolve the saveall() issue now, still can get that to work. I ll get
back to you on that as well.

On Nov 14, 8:44 am, Pablo Terradillos  wrote:
> Also, have you tried to generate code with bake? it could be helpful or you
> could see what are you doing wrong at least
>
> http://book.cakephp.org/view/1522/Code-Generation-with-Bake
> Pablo E. Terradillos
>
> On Sun, Nov 14, 2010 at 12:43 AM, Pablo Terradillos wrote:
>
> > I'm not sure if i understand correctly your first issue...
> > Have your associated model the corresponding foreign key and, also, a
> > primary key?
> > For example,
>
> > Questions
> > id
> > text
>
> > Answers
> > id
> > question_id
> > text
>
> > Regarding the second issue,
>
> > remember to enclose modelName.$i.field with double quotes so $i is treated
> > as a variable or you could use 'modelName.'.$i.'field'
>
> > Pablo E. Terradillos
>
> > On Sat, Nov 13, 2010 at 11:39 PM, Rameez  wrote:
>
> >> Thank you for your response, I in fact did do what you said about the
> >> first problem and resolved that error. I was passing the parameter to
> >> a page that has a form. The create function in the view, would recall
> >> the same action using the $options as 'action'. I added the 'url tag
> >> to the' $options array. Without the tag my parameters kept
> >> disappearing
>
> >> 1) However now I have come across a new problem. The parameter I pass
> >> is to set the foreign key field of the Question (Survey ID). But when
> >> I save $this->data, it takes the id to be the same argument
> >> automatically. So it goes into the database and over writes the entry
> >> with that ID instead of making a new entry.
> >>  Here is my view code:
>
> >> echo $form->create('ModelName', array('url' => array('action' =>
> >> 'create',$this->passedArgs[0])));
> >> echo $form->input('text',array('label'=> 'Enter the Question Text'));
> >> echo '
> >> echo $form->end();
>
> >> Inside the controller i just try to debug the id
> >> Code:
> >> if (!empty($this->data)) {
> >>     debug($this->ModelName->id);
> >>     $this->ModelName->save($this->data, array('validate' => true));
> >>     redirect(somewhere);
> >> }
>
> >> 2) As for the second question, saveAll() tries to save all the answers
> >> options with the same primary id which is zero for this case. If I use
> >> a loop I change the syntax like this ModelName.0.FieldName becomes
> >> ModelName.$i.Fieldname where $i is the loop variable. This doesnt save
> >> anything.
>
> >> On Nov 14, 3:45 am, Pablo Terradillos  wrote:
> >> > Have your model the corresponding associations?
> >> > Questions have many answers?
>
> >> > if so, you could check what your form is POSTing using
> >> debug($this->data);
> >> > in order to check if you are making all in a the correct way
>
> >> > You may not have any problems putting the form generator in a loop, as
> >> long
> >> > as your associations are correct (is saveAll working whenever you try to
> >> > save the answers without the loop?)
>
> >> > Pablo E. Terradillos
>
> >> > On Fri, Nov 12, 2010 at 10:53 PM, Rameez 
> >> wrote:
> >> > > I am new to cake php so please bear with me. I am trying to create a
> >> > > survey for which i can create multiple choice questions. i am running
> >> > > into two issues
>
> >> > > 1) for multiple choice questions i have a form that takes all the
> >> > > answer choices and saves them as separate entries inside the answers
> >> > > database table. Can someone tell me how to take same input field for
> >> > > multiple entries in a loop? This because i have a varying number of
> >> > > answer choices for every question. The cook book only shows how to it
> >> > > indivudially using 'Modelname.0.fieldname' and Modelname.1.fieldname
> >> > > and so on. I tried replacing the numbers with a loop variable but then
> >> > > the saveall() didnt work?
>
> >> > > 2) i cant pass parameters from an action inside the surveys controller
> >> > > to an action inside the questions controller. Can someone help me with
> >> > > this? The url indicates that the parameter is being passed, but the
> >> > > receiving function always gets a null.
>
> >> > > Could someone help me with this. Thank you in advance.
>
> >> > > 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 at
> >> > >http://groups.google.com/group/cake-php?hl=en
>
> >> Check out the new CakePHP Questi

Re: Making Forms using Loops for Populating Multiple Database Entries

2010-11-14 Thread Rameez
No I haven't used Bake as yet, but the structure is really simple. I
ll skip the answers part because that is not relevant here

Survey Model
---ID (primary key)
---Name

Question Model
---ID (primary key)
---Text
---Survey ID (foreign key)

so what happens is I am looking at all the surveys I have, and I
decide to add a question to a particular survey, so I call the add
function from questions controller passing it the parameter,
(survey_id) to use for its foreign key field. The add action is a form
where i take the question text and recalls the same add action with
$this->data and the passed parameter.

function add($surveyid=null)

debug($this->Question->id);
if (!empty($this->data)) {
$this->data['Question']['survey_id']= $surveyid;
if($this->MasterQuestion->save($this->data, array('validate' =>
true))){
   //redirect me to another page
}
}
}

Now when we submit the form and enter the function, $this->Question-
>id is magically made equal to the $surveyid. So when save() is called
it thinks that it needs to update the db which has the given id. As
you can see the the debug function is outside the if statement so it
runs even before i press submit. If i pass parameter 1($surveyid = 1),
$this->Question->id is set to 1.  If i pass parameter =2,  $this-
>Question->id is set to 2 and so on. Thanks.


On Nov 14, 8:44 am, Pablo Terradillos  wrote:
> Also, have you tried to generate code with bake? it could be helpful or you
> could see what are you doing wrong at least
>
> http://book.cakephp.org/view/1522/Code-Generation-with-Bake
> Pablo E. Terradillos
>
> On Sun, Nov 14, 2010 at 12:43 AM, Pablo Terradillos wrote:
>
> > I'm not sure if i understand correctly your first issue...
> > Have your associated model the corresponding foreign key and, also, a
> > primary key?
> > For example,
>
> > Questions
> > id
> > text
>
> > Answers
> > id
> > question_id
> > text
>
> > Regarding the second issue,
>
> > remember to enclose modelName.$i.field with double quotes so $i is treated
> > as a variable or you could use 'modelName.'.$i.'field'
>
> > Pablo E. Terradillos
>
> > On Sat, Nov 13, 2010 at 11:39 PM, Rameez  wrote:
>
> >> Thank you for your response, I in fact did do what you said about the
> >> first problem and resolved that error. I was passing the parameter to
> >> a page that has a form. The create function in the view, would recall
> >> the same action using the $options as 'action'. I added the 'url tag
> >> to the' $options array. Without the tag my parameters kept
> >> disappearing
>
> >> 1) However now I have come across a new problem. The parameter I pass
> >> is to set the foreign key field of the Question (Survey ID). But when
> >> I save $this->data, it takes the id to be the same argument
> >> automatically. So it goes into the database and over writes the entry
> >> with that ID instead of making a new entry.
> >>  Here is my view code:
>
> >> echo $form->create('ModelName', array('url' => array('action' =>
> >> 'create',$this->passedArgs[0])));
> >> echo $form->input('text',array('label'=> 'Enter the Question Text'));
> >> echo '
> >> echo $form->end();
>
> >> Inside the controller i just try to debug the id
> >> Code:
> >> if (!empty($this->data)) {
> >>     debug($this->ModelName->id);
> >>     $this->ModelName->save($this->data, array('validate' => true));
> >>     redirect(somewhere);
> >> }
>
> >> 2) As for the second question, saveAll() tries to save all the answers
> >> options with the same primary id which is zero for this case. If I use
> >> a loop I change the syntax like this ModelName.0.FieldName becomes
> >> ModelName.$i.Fieldname where $i is the loop variable. This doesnt save
> >> anything.
>
> >> On Nov 14, 3:45 am, Pablo Terradillos  wrote:
> >> > Have your model the corresponding associations?
> >> > Questions have many answers?
>
> >> > if so, you could check what your form is POSTing using
> >> debug($this->data);
> >> > in order to check if you are making all in a the correct way
>
> >> > You may not have any problems putting the form generator in a loop, as
> >> long
> >> > as your associations are correct (is saveAll working whenever you try to
> >> > save the answers without the loop?)
>
> >> > Pablo E. Terradillos
>
> >> > On Fri, Nov 12, 2010 at 10:53 PM, Rameez 
> >> wrote:
> >> > > I am new to cake php so please bear with me. I am trying to create a
> >> > > survey for which i can create multiple choice questions. i am running
> >> > > into two issues
>
> >> > > 1) for multiple choice questions i have a form that takes all the
> >> > > answer choices and saves them as separate entries inside the answers
> >> > > database table. Can someone tell me how to take same input field for
> >> > > multiple entries in a loop? This because i have a varying number of
> >> > > answer choices for every question. The cook book only shows how to it
> >> > > indivudially using 'Modelname.0.fieldn

Re: Making Forms using Loops for Populating Multiple Database Entries

2010-11-13 Thread Pablo Terradillos
Also, have you tried to generate code with bake? it could be helpful or you
could see what are you doing wrong at least


http://book.cakephp.org/view/1522/Code-Generation-with-Bake
Pablo E. Terradillos



On Sun, Nov 14, 2010 at 12:43 AM, Pablo Terradillos wrote:

> I'm not sure if i understand correctly your first issue...
> Have your associated model the corresponding foreign key and, also, a
> primary key?
> For example,
>
> Questions
> id
> text
>
> Answers
> id
> question_id
> text
>
>
>
> Regarding the second issue,
>
> remember to enclose modelName.$i.field with double quotes so $i is treated
> as a variable or you could use 'modelName.'.$i.'field'
>
> Pablo E. Terradillos
>
>
>
>
> On Sat, Nov 13, 2010 at 11:39 PM, Rameez  wrote:
>
>> Thank you for your response, I in fact did do what you said about the
>> first problem and resolved that error. I was passing the parameter to
>> a page that has a form. The create function in the view, would recall
>> the same action using the $options as 'action'. I added the 'url tag
>> to the' $options array. Without the tag my parameters kept
>> disappearing
>>
>> 1) However now I have come across a new problem. The parameter I pass
>> is to set the foreign key field of the Question (Survey ID). But when
>> I save $this->data, it takes the id to be the same argument
>> automatically. So it goes into the database and over writes the entry
>> with that ID instead of making a new entry.
>>  Here is my view code:
>>
>> echo $form->create('ModelName', array('url' => array('action' =>
>> 'create',$this->passedArgs[0])));
>> echo $form->input('text',array('label'=> 'Enter the Question Text'));
>> echo '
>> echo $form->end();
>>
>> Inside the controller i just try to debug the id
>> Code:
>> if (!empty($this->data)) {
>> debug($this->ModelName->id);
>> $this->ModelName->save($this->data, array('validate' => true));
>> redirect(somewhere);
>> }
>>
>>
>>
>> 2) As for the second question, saveAll() tries to save all the answers
>> options with the same primary id which is zero for this case. If I use
>> a loop I change the syntax like this ModelName.0.FieldName becomes
>> ModelName.$i.Fieldname where $i is the loop variable. This doesnt save
>> anything.
>>
>>
>>
>>
>>
>> On Nov 14, 3:45 am, Pablo Terradillos  wrote:
>> > Have your model the corresponding associations?
>> > Questions have many answers?
>> >
>> > if so, you could check what your form is POSTing using
>> debug($this->data);
>> > in order to check if you are making all in a the correct way
>> >
>> > You may not have any problems putting the form generator in a loop, as
>> long
>> > as your associations are correct (is saveAll working whenever you try to
>> > save the answers without the loop?)
>> >
>> > Pablo E. Terradillos
>> >
>> > On Fri, Nov 12, 2010 at 10:53 PM, Rameez 
>> wrote:
>> > > I am new to cake php so please bear with me. I am trying to create a
>> > > survey for which i can create multiple choice questions. i am running
>> > > into two issues
>> >
>> > > 1) for multiple choice questions i have a form that takes all the
>> > > answer choices and saves them as separate entries inside the answers
>> > > database table. Can someone tell me how to take same input field for
>> > > multiple entries in a loop? This because i have a varying number of
>> > > answer choices for every question. The cook book only shows how to it
>> > > indivudially using 'Modelname.0.fieldname' and Modelname.1.fieldname
>> > > and so on. I tried replacing the numbers with a loop variable but then
>> > > the saveall() didnt work?
>> >
>> > > 2) i cant pass parameters from an action inside the surveys controller
>> > > to an action inside the questions controller. Can someone help me with
>> > > this? The url indicates that the parameter is being passed, but the
>> > > receiving function always gets a null.
>> >
>> > > Could someone help me with this. Thank you in advance.
>> >
>> > > Check out the new CakePHP Questions sitehttp://cakeqs.organd 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
>>
>> 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.comFor
>>  more options, visit this group at
>> http://groups.google.com/group/cake-php?hl=en
>>
>
>

Check out the new CakePHP Questions site http://cakeqs.org and help other

Re: Making Forms using Loops for Populating Multiple Database Entries

2010-11-13 Thread Pablo Terradillos
I'm not sure if i understand correctly your first issue...
Have your associated model the corresponding foreign key and, also, a
primary key?
For example,

Questions
id
text

Answers
id
question_id
text



Regarding the second issue,

remember to enclose modelName.$i.field with double quotes so $i is treated
as a variable or you could use 'modelName.'.$i.'field'

Pablo E. Terradillos



On Sat, Nov 13, 2010 at 11:39 PM, Rameez  wrote:

> Thank you for your response, I in fact did do what you said about the
> first problem and resolved that error. I was passing the parameter to
> a page that has a form. The create function in the view, would recall
> the same action using the $options as 'action'. I added the 'url tag
> to the' $options array. Without the tag my parameters kept
> disappearing
>
> 1) However now I have come across a new problem. The parameter I pass
> is to set the foreign key field of the Question (Survey ID). But when
> I save $this->data, it takes the id to be the same argument
> automatically. So it goes into the database and over writes the entry
> with that ID instead of making a new entry.
>  Here is my view code:
>
> echo $form->create('ModelName', array('url' => array('action' =>
> 'create',$this->passedArgs[0])));
> echo $form->input('text',array('label'=> 'Enter the Question Text'));
> echo '
> echo $form->end();
>
> Inside the controller i just try to debug the id
> Code:
> if (!empty($this->data)) {
> debug($this->ModelName->id);
> $this->ModelName->save($this->data, array('validate' => true));
> redirect(somewhere);
> }
>
>
>
> 2) As for the second question, saveAll() tries to save all the answers
> options with the same primary id which is zero for this case. If I use
> a loop I change the syntax like this ModelName.0.FieldName becomes
> ModelName.$i.Fieldname where $i is the loop variable. This doesnt save
> anything.
>
>
>
>
>
> On Nov 14, 3:45 am, Pablo Terradillos  wrote:
> > Have your model the corresponding associations?
> > Questions have many answers?
> >
> > if so, you could check what your form is POSTing using
> debug($this->data);
> > in order to check if you are making all in a the correct way
> >
> > You may not have any problems putting the form generator in a loop, as
> long
> > as your associations are correct (is saveAll working whenever you try to
> > save the answers without the loop?)
> >
> > Pablo E. Terradillos
> >
> > On Fri, Nov 12, 2010 at 10:53 PM, Rameez 
> wrote:
> > > I am new to cake php so please bear with me. I am trying to create a
> > > survey for which i can create multiple choice questions. i am running
> > > into two issues
> >
> > > 1) for multiple choice questions i have a form that takes all the
> > > answer choices and saves them as separate entries inside the answers
> > > database table. Can someone tell me how to take same input field for
> > > multiple entries in a loop? This because i have a varying number of
> > > answer choices for every question. The cook book only shows how to it
> > > indivudially using 'Modelname.0.fieldname' and Modelname.1.fieldname
> > > and so on. I tried replacing the numbers with a loop variable but then
> > > the saveall() didnt work?
> >
> > > 2) i cant pass parameters from an action inside the surveys controller
> > > to an action inside the questions controller. Can someone help me with
> > > this? The url indicates that the parameter is being passed, but the
> > > receiving function always gets a null.
> >
> > > Could someone help me with this. Thank you in advance.
> >
> > > Check out the new CakePHP Questions sitehttp://cakeqs.organd 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
>
> 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.comFor
>  more options, visit this group at
> http://groups.google.com/group/cake-php?hl=en
>

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

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


Re: Making Forms using Loops for Populating Multiple Database Entries

2010-11-13 Thread Rameez
Thank you for your response, I in fact did do what you said about the
first problem and resolved that error. I was passing the parameter to
a page that has a form. The create function in the view, would recall
the same action using the $options as 'action'. I added the 'url tag
to the' $options array. Without the tag my parameters kept
disappearing

1) However now I have come across a new problem. The parameter I pass
is to set the foreign key field of the Question (Survey ID). But when
I save $this->data, it takes the id to be the same argument
automatically. So it goes into the database and over writes the entry
with that ID instead of making a new entry.
 Here is my view code:

echo $form->create('ModelName', array('url' => array('action' =>
'create',$this->passedArgs[0])));
echo $form->input('text',array('label'=> 'Enter the Question Text'));
echo '
echo $form->end();

Inside the controller i just try to debug the id
Code:
if (!empty($this->data)) {
 debug($this->ModelName->id);
 $this->ModelName->save($this->data, array('validate' => true));
 redirect(somewhere);
}



2) As for the second question, saveAll() tries to save all the answers
options with the same primary id which is zero for this case. If I use
a loop I change the syntax like this ModelName.0.FieldName becomes
ModelName.$i.Fieldname where $i is the loop variable. This doesnt save
anything.





On Nov 14, 3:45 am, Pablo Terradillos  wrote:
> Have your model the corresponding associations?
> Questions have many answers?
>
> if so, you could check what your form is POSTing using debug($this->data);
> in order to check if you are making all in a the correct way
>
> You may not have any problems putting the form generator in a loop, as long
> as your associations are correct (is saveAll working whenever you try to
> save the answers without the loop?)
>
> Pablo E. Terradillos
>
> On Fri, Nov 12, 2010 at 10:53 PM, Rameez  wrote:
> > I am new to cake php so please bear with me. I am trying to create a
> > survey for which i can create multiple choice questions. i am running
> > into two issues
>
> > 1) for multiple choice questions i have a form that takes all the
> > answer choices and saves them as separate entries inside the answers
> > database table. Can someone tell me how to take same input field for
> > multiple entries in a loop? This because i have a varying number of
> > answer choices for every question. The cook book only shows how to it
> > indivudially using 'Modelname.0.fieldname' and Modelname.1.fieldname
> > and so on. I tried replacing the numbers with a loop variable but then
> > the saveall() didnt work?
>
> > 2) i cant pass parameters from an action inside the surveys controller
> > to an action inside the questions controller. Can someone help me with
> > this? The url indicates that the parameter is being passed, but the
> > receiving function always gets a null.
>
> > Could someone help me with this. Thank you in advance.
>
> > Check out the new CakePHP Questions sitehttp://cakeqs.organd 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.comFor
> >  more options, visit this group at
> >http://groups.google.com/group/cake-php?hl=en

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

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


Re: Making Forms using Loops for Populating Multiple Database Entries

2010-11-13 Thread Pablo Terradillos
Have your model the corresponding associations?
Questions have many answers?

if so, you could check what your form is POSTing using debug($this->data);
in order to check if you are making all in a the correct way

You may not have any problems putting the form generator in a loop, as long
as your associations are correct (is saveAll working whenever you try to
save the answers without the loop?)


Pablo E. Terradillos



On Fri, Nov 12, 2010 at 10:53 PM, Rameez  wrote:

> I am new to cake php so please bear with me. I am trying to create a
> survey for which i can create multiple choice questions. i am running
> into two issues
>
> 1) for multiple choice questions i have a form that takes all the
> answer choices and saves them as separate entries inside the answers
> database table. Can someone tell me how to take same input field for
> multiple entries in a loop? This because i have a varying number of
> answer choices for every question. The cook book only shows how to it
> indivudially using 'Modelname.0.fieldname' and Modelname.1.fieldname
> and so on. I tried replacing the numbers with a loop variable but then
> the saveall() didnt work?
>
> 2) i cant pass parameters from an action inside the surveys controller
> to an action inside the questions controller. Can someone help me with
> this? The url indicates that the parameter is being passed, but the
> receiving function always gets a null.
>
> Could someone help me with this. Thank you in advance.
>
> 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.comFor
>  more options, visit this group at
> http://groups.google.com/group/cake-php?hl=en
>

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

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


Making Forms using Loops for Populating Multiple Database Entries

2010-11-13 Thread Rameez
I am new to cake php so please bear with me. I am trying to create a
survey for which i can create multiple choice questions. i am running
into two issues

1) for multiple choice questions i have a form that takes all the
answer choices and saves them as separate entries inside the answers
database table. Can someone tell me how to take same input field for
multiple entries in a loop? This because i have a varying number of
answer choices for every question. The cook book only shows how to it
indivudially using 'Modelname.0.fieldname' and Modelname.1.fieldname
and so on. I tried replacing the numbers with a loop variable but then
the saveall() didnt work?

2) i cant pass parameters from an action inside the surveys controller
to an action inside the questions controller. Can someone help me with
this? The url indicates that the parameter is being passed, but the
receiving function always gets a null.

Could someone help me with this. Thank you in advance.

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: Named parameters, forms and redirects

2010-11-06 Thread WebbedIT
Nah, deffo not doing anything wrong, just getting used to the
framework :)

Although I do advise spending time trying to do everything to the best
of your ability first time around.  You will reuse a lot of CRUD code
throughout other models/controllers/views.  With my first CakePHP
project I had over 50 models and by the time I had finished I had
probably bettered my early model/contoller/views twice.

Nothing worse than having one model expecting variables in a different
way to another and possibly behaving different across one app.

HTH, Paul

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: Named parameters, forms and redirects

2010-11-05 Thread chris
Thanks for your reply and suggestions, I have adjusted my code since
and it seems to be working fine, will look at these options as well
and see how I can improve it.

At least it dosn't sound like I am doing something completely wrong.

On Nov 4, 10:05 pm, WebbedIT  wrote:
> As I suspected, the issue is when you initially request the form you
> are passing it in via $_GET as a named parameter, then when you submit
> the form you change to passing it in via $_POST into the model's data
> array instead.
>
> I actually do it this way myself and have my method specified as
> something like
>
> function add($foreign_id = null) {
>   $foreign_id = $data['Model']['foreign_id'] ? $data['Model']
> ['foreign_id'] : $foreign_id;
>   if (!$foreign_id) {
>     // error
>   }
>
> }
>
> You could move this logic to the controllers isAuthorized() method to
> throw an auth error
>
> function isAuthorized() {
>   switch ($this->action) {
>     case 'add':
>       $foreign_id = $this->data['Model']['foreign_id'] ? $data['Model']
> ['foreign_id'] : $this->params['named']['foreign_id'];
>       if (!$foreign_id) return false;
>       break;
>   }
>   return true;
>
> }
>
> but I think this is wrong as the existence of a foreign_id is not
> really an Auth issue.  The other method would be to  amend $form-
>
> >create in your view so the form submits to '/model/add/foreign_id:1'
>
> No hard and fast answer really.
>
> HTH, Paul.

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: Named parameters, forms and redirects

2010-11-04 Thread WebbedIT
As I suspected, the issue is when you initially request the form you
are passing it in via $_GET as a named parameter, then when you submit
the form you change to passing it in via $_POST into the model's data
array instead.

I actually do it this way myself and have my method specified as
something like

function add($foreign_id = null) {
  $foreign_id = $data['Model']['foreign_id'] ? $data['Model']
['foreign_id'] : $foreign_id;
  if (!$foreign_id) {
// error
  }
}

You could move this logic to the controllers isAuthorized() method to
throw an auth error

function isAuthorized() {
  switch ($this->action) {
case 'add':
  $foreign_id = $this->data['Model']['foreign_id'] ? $data['Model']
['foreign_id'] : $this->params['named']['foreign_id'];
  if (!$foreign_id) return false;
  break;
  }
  return true;
}

but I think this is wrong as the existence of a foreign_id is not
really an Auth issue.  The other method would be to  amend $form-
>create in your view so the form submits to '/model/add/foreign_id:1'

No hard and fast answer really.

HTH, Paul.

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: Named parameters, forms and redirects

2010-11-04 Thread chris
Thanks for the reply, I seem to have found a way to make this work, by
only checking for the parameter if $data is empty, as otherwise the id
is kept in the data array.

But still not sure if I'm doing things right.

To answer your points below

1.This bit of code is the only part which is doing anything related to
accepting the parameter, the passedArgs seems to be automatically
filled in.

if(isset($this->passedArgs['foreign_id']))
$this->data['model']['foreign_id'] = $this-
>passedArgs['foreign_id'];

2. I do not explicitly pass it to the view, the above code puts the
parameter into the data variable.
3.The form is generated by the form helper, this line is used for the
forigen key, the value gets automaically filled in when I have
assigned it to the data variable,

echo $this->Form->input('foreign_id',array( 'type' => 'hidden'));

Thanks

On Nov 4, 1:45 pm, WebbedIT  wrote:
> Hi,
>
> Need to post the relevant parts of your controller and view so that we
> can see how you are
>
> 1. accepting the variable into your controller method
> 2. passing it to your view
> 3. including it in the form to pass it back to the controller.
>
> HTH, Paul

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: Named parameters, forms and redirects

2010-11-04 Thread WebbedIT
Hi,

Need to post the relevant parts of your controller and view so that we
can see how you are

1. accepting the variable into your controller method
2. passing it to your view
3. including it in the form to pass it back to the controller.

HTH, Paul

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


Named parameters, forms and redirects

2010-11-04 Thread chris
I'm passing a foreign id to my models add funtion via a URL such as

/model/add/foreign_id:1

The /add/ method generates an error and redirects if it does not
receive this parameter.

I assign the foreign id to the model and it auto populates the form

if(isset($this->passedArgs['foreign_id']))
$this->data['model']['foreign_id'] = $this->passedArgs['foreign_id'];

This all works, until the form has a validation error and has to be re-
displayed to the user. The URL then changes to

/model/add/

So the foreign_id information is then lost.

Firstly, is what I'm doing correct, and how can I fix this issue?

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


Multiple Forms in the same controller / model to be validated differently?

2010-09-08 Thread Shaz
Here's an old article that shows how to do exactly what I want - but
doesn't quite work:

http://bakery.cakephp.org/articles/view/multiple-forms-per-page-for-the-same-model

Any other way of using CakePHPs form validation on different forms? I
have an add, edit function/view/form for my controller and I want to
validate different rules on the forms...

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


Why cakephp forms doesn't work with jquery (mb)menu ?

2010-08-31 Thread keresh
Hi

In my menu (jquery plugin named (mb)Menu) i wrote a simple login form:



 Login panel
  
 
  create('User', array('action' => 'login')); ?>
  login:
  input('username', array('label' => '')); ?>
  password:
  input('password', array('type' => 'password',
'label' => '')); ?>
  end('Log in!'); ?>
 


Aftet pressing on submit button nothing is happening.

This form works well outside this menu.

Can somebody tell me why it isnt working ?

Thanks for your help.

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

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


Re: Models, joins and forms

2010-07-23 Thread Joachim Nyqvist
I figured it out. I'm suppose to put the belongsTo in the models not
the controllers.

On 23 Juli, 13:10, Joachim Nyqvist  wrote:
> Ok. I have changed the tables and these are my files:
>
>  /**
>  * @property Merit $Merit
>  */
>
> class Merit extends AppModel {
>
>     var $name = 'Merit';}
>
> ?>
>
> -
>
>  /**
>  * @property Category $Category
>  */
>
> class Category extends AppModel {
>
>     var $name = 'Category';}
>
> ?>
>
> -
>
>  /**
>  * @property Merits $Merits
>  */
>
> class CategoriesController extends AppController {
>
>     var $name = 'Categories';
>
>     var $hasMany = array(
>         'Merit' => array(
>             'className'     => 'Merit',
>             'foreignKey'    => 'category_id',
>         )
>     );
>
> }
>
> ?>
>
> -
>
>  /**
>  * @property Merits $Merits
>  */
>
> class MeritsController extends AppController {
>
>     var $name = 'Merits';
>
>     var $belongsTo = array(
>         'Category' => array(
>             'className'    => 'Category',
>             'foreignKey'    => 'category_id'
>         )
>     );
>
>     function index() {
>
>         $this->layout = 'cv';
>
>         $this->set('utbildning', $this->Merit->find('all', array(
>             'conditions' => array('Merit.category_id' => 1),
>             'order' => array('Merit.modified DESC')
>         )));
>
>     function edit($id = null) {
>         $this->Merit->id = $id;
>         if (empty($this->data)) {
>             $this->data = $this->Merit->read();
>         }
>         else {
>             if ($this->Merit->save($this->data)) {
>                 $this->Session->setFlash('Meriten har uppdaterats.');
>                 $this->redirect(array('controller' => 'merits',
> 'action' => 'index'));
>             }
>         }
>     }}
>
> ?>
>
> Now to my issue. How do I do with the edit-action? It saves everything
> to a single table, however I would like to have a
> 
> ['Category']['name']
> ['Category']['name']
> ['Category']['name']
> 
>
> and post the value to ['Merit']['categories_id'].
>
> How do I do that?
>
> On 23 Juli, 10:54, Joachim Nyqvist  wrote:
>
> > No need to apologize about language. I was just lazy, so I didn't
> > translate, I just wanted to show which columns where corresponding.
>
> > Thanks for the answer. I will certainly look into this in detail when
> > I have a little more time over.
>
> > You're definitely right about dropping the join-table. As the setup is
> > today, a record can belong to many categories, however that wasn't the
> > intention. The intention was only one category per record. I don't
> > really know why I made it more complicated. So "Category hasMany
> > Record" and "Record belongsTo Category" makes perfect sense.
>
> > On 22 Juli, 21:23, cricket  wrote:
>
> > > On Thu, Jul 22, 2010 at 10:36 AM, Joachim Nyqvist  
> > > wrote:
> > > > Ok, I'm new to Cake, but not php. I don't know how to build my models
> > > > for easy creation of add, edit and delete actions.
>
> > > > I have three tables:
>
> > > > The records:
>
> > > > CREATE TABLE merits (
> > > >  meritId int(10) unsigned NOT NULL AUTO_INCREMENT,
> > > >  ar varchar(20) DEFAULT NULL,
> > > >  titel varchar(40) NOT NULL,
> > > >  plats varchar(40) DEFAULT NULL,
> > > >  stad varchar(40) DEFAULT NULL,
> > > >  beskrivning text,
> > > >  modifierad timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE
> > > > CURRENT_TIMESTAMP,
> > > >  PRIMARY KEY (meritId)
> > > > ) ENGINE=InnoDB  DEFAULT CHARSET=latin1;
>
> > > > The categories:
>
> > > > CREATE TABLE kategoris (
> > > >  kategoriId int(10) unsigned NOT NULL AUTO_INCREMENT,
> > > >  kategoriNamn varchar(40) NOT NULL,
> > > >  PRIMARY KEY (kategoriId)
> > > > ) ENGINE=MyISAM  DEFAULT CHARSET=latin1;
>
> > > > and the table to connect categories and the records:
>
> > > > CREATE TABLE cvs (
> > > >  kategoriId int(10) unsigned NOT NULL,
> > > >  meritId int(10) unsigned NOT NULL,
> > > >  PRIMARY KEY (kategoriId,meritId)
> > > > ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
>
> > > > For now I have managed to produce a index view with the following:
>
> > > >  > > > /**
> > > >  * @property Cvs $Cvs
> > > >  */
>
> > > > class CvsController extends AppController {
>
> > > >    var $name = 'Cvs';
> > > >    var $helpers = array('Minify', 'Mailto');
>
> > > >    function index() {
>
> > > >        $this->layout = 'cv';
>
> > > >        $this->set('utbildning', $this->Cv->query("SELECT merits.ar,
> > > > merits.titel, merits.plats, merits.stad, merits.beskrivning FROM
> > > > merits JOIN cvs ON merits.meritId = cvs.meritId JOIN kategoris ON
> > > > cvs.kategoriId = kategoris.kategoriId WHERE kategoris.kategoriNamn =
> > > > 'Utbildning' ORDER BY merits.modifierad DESC;"));
> > > >    }
> > > > }
> > > > ?>
>
> > > > A simple SQL-query, because I know how to work them.
>
> > > > Now, I don't know how to write the models, so i can add the other
> > > > actions, add, edit, delete.

Re: Multiple login forms submitting to one login action

2010-07-23 Thread tersmitten
I already found the solution myself. It was because of the stupid
pages controller :-(

http://stackoverflow.com/questions/3302798/multiple-login-forms-submitting-to-one-login-action

On 22 jul, 19:05, cricket  wrote:
> On Wed, Jul 21, 2010 at 3:02 PM, tersmitten
>
>  wrote:
> > I'm having 2loginformsin my (cake) application.Oneon the home
> > page (served by pages controller) andonein my user controller. The
> >onefrom my user controller is working fine. But when I try tologin
> > from the homepage I get a blank page and I see in firebug I got a 404.
> > The strange thing is that the session is setup OK.
>
> Set debug to 2. When it's at 0, Cake throws a 404 when it encounters
> an error. This is so it doesn't reveal them in production mode. You
> probably have some unrelated error happening.
>
> > It's looks like it has something to do with $this->Auth->autoRedirect
> > = false (which is set in user controller beforeFilter()). What could
> > be the problem?
>
> That should go in AppController::beforeFilter()

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: Models, joins and forms

2010-07-23 Thread Joachim Nyqvist
Ok. I have changed the tables and these are my files:



-



-

 array(
'className' => 'Merit',
'foreignKey'=> 'category_id',
)
);
}

?>

-

 array(
'className'=> 'Category',
'foreignKey'=> 'category_id'
)
);

function index() {

$this->layout = 'cv';

$this->set('utbildning', $this->Merit->find('all', array(
'conditions' => array('Merit.category_id' => 1),
'order' => array('Merit.modified DESC')
)));

function edit($id = null) {
$this->Merit->id = $id;
if (empty($this->data)) {
$this->data = $this->Merit->read();
}
else {
if ($this->Merit->save($this->data)) {
$this->Session->setFlash('Meriten har uppdaterats.');
$this->redirect(array('controller' => 'merits',
'action' => 'index'));
}
}
}
}
?>

Now to my issue. How do I do with the edit-action? It saves everything
to a single table, however I would like to have a

['Category']['name']
['Category']['name']
['Category']['name']


and post the value to ['Merit']['categories_id'].

How do I do that?

On 23 Juli, 10:54, Joachim Nyqvist  wrote:
> No need to apologize about language. I was just lazy, so I didn't
> translate, I just wanted to show which columns where corresponding.
>
> Thanks for the answer. I will certainly look into this in detail when
> I have a little more time over.
>
> You're definitely right about dropping the join-table. As the setup is
> today, a record can belong to many categories, however that wasn't the
> intention. The intention was only one category per record. I don't
> really know why I made it more complicated. So "Category hasMany
> Record" and "Record belongsTo Category" makes perfect sense.
>
> On 22 Juli, 21:23, cricket  wrote:
>
> > On Thu, Jul 22, 2010 at 10:36 AM, Joachim Nyqvist  
> > wrote:
> > > Ok, I'm new to Cake, but not php. I don't know how to build my models
> > > for easy creation of add, edit and delete actions.
>
> > > I have three tables:
>
> > > The records:
>
> > > CREATE TABLE merits (
> > >  meritId int(10) unsigned NOT NULL AUTO_INCREMENT,
> > >  ar varchar(20) DEFAULT NULL,
> > >  titel varchar(40) NOT NULL,
> > >  plats varchar(40) DEFAULT NULL,
> > >  stad varchar(40) DEFAULT NULL,
> > >  beskrivning text,
> > >  modifierad timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE
> > > CURRENT_TIMESTAMP,
> > >  PRIMARY KEY (meritId)
> > > ) ENGINE=InnoDB  DEFAULT CHARSET=latin1;
>
> > > The categories:
>
> > > CREATE TABLE kategoris (
> > >  kategoriId int(10) unsigned NOT NULL AUTO_INCREMENT,
> > >  kategoriNamn varchar(40) NOT NULL,
> > >  PRIMARY KEY (kategoriId)
> > > ) ENGINE=MyISAM  DEFAULT CHARSET=latin1;
>
> > > and the table to connect categories and the records:
>
> > > CREATE TABLE cvs (
> > >  kategoriId int(10) unsigned NOT NULL,
> > >  meritId int(10) unsigned NOT NULL,
> > >  PRIMARY KEY (kategoriId,meritId)
> > > ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
>
> > > For now I have managed to produce a index view with the following:
>
> > >  > > /**
> > >  * @property Cvs $Cvs
> > >  */
>
> > > class CvsController extends AppController {
>
> > >    var $name = 'Cvs';
> > >    var $helpers = array('Minify', 'Mailto');
>
> > >    function index() {
>
> > >        $this->layout = 'cv';
>
> > >        $this->set('utbildning', $this->Cv->query("SELECT merits.ar,
> > > merits.titel, merits.plats, merits.stad, merits.beskrivning FROM
> > > merits JOIN cvs ON merits.meritId = cvs.meritId JOIN kategoris ON
> > > cvs.kategoriId = kategoris.kategoriId WHERE kategoris.kategoriNamn =
> > > 'Utbildning' ORDER BY merits.modifierad DESC;"));
> > >    }
> > > }
> > > ?>
>
> > > A simple SQL-query, because I know how to work them.
>
> > > Now, I don't know how to write the models, so i can add the other
> > > actions, add, edit, delete. After some researches, I think it has
> > > something to do with (hasOne, hasMany, belongsTo) but would certainly
> > > need some help.
>
> > Yes, you should be following Cake's conventions so that you can take
> > advantage of associations (hasOne, etc.). However, I'm goingto have to
> > show you using english, simply because I'm unsure of the inflections.
> > Sorry about that. Maybe someone else can adjust this to use your
> > laguage.
>
> > First thing, use "id" for the PK:
>
> > CREATE TABLE merits (
> >         id int(10) unsigned NOT NULL AUTO_INCREMENT,
> >         ar varchar(20) DEFAULT NULL,
> >         titel varchar(40) NOT NULL,
> >         plats varchar(40) DEFAULT NULL,
> >         stad varchar(40) DEFAULT NULL,
> >         beskrivning text,
> >         modifierad timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE
> >         CURRENT_TIMESTAMP,
> >         PRIMARY KEY (meritId)
> > ) ENGINE=InnoDB  DEFAULT CHARSET=latin1;
>

Re: Models, joins and forms

2010-07-23 Thread Joachim Nyqvist
No need to apologize about language. I was just lazy, so I didn't
translate, I just wanted to show which columns where corresponding.

Thanks for the answer. I will certainly look into this in detail when
I have a little more time over.

You're definitely right about dropping the join-table. As the setup is
today, a record can belong to many categories, however that wasn't the
intention. The intention was only one category per record. I don't
really know why I made it more complicated. So "Category hasMany
Record" and "Record belongsTo Category" makes perfect sense.

On 22 Juli, 21:23, cricket  wrote:
> On Thu, Jul 22, 2010 at 10:36 AM, Joachim Nyqvist  wrote:
> > Ok, I'm new to Cake, but not php. I don't know how to build my models
> > for easy creation of add, edit and delete actions.
>
> > I have three tables:
>
> > The records:
>
> > CREATE TABLE merits (
> >  meritId int(10) unsigned NOT NULL AUTO_INCREMENT,
> >  ar varchar(20) DEFAULT NULL,
> >  titel varchar(40) NOT NULL,
> >  plats varchar(40) DEFAULT NULL,
> >  stad varchar(40) DEFAULT NULL,
> >  beskrivning text,
> >  modifierad timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE
> > CURRENT_TIMESTAMP,
> >  PRIMARY KEY (meritId)
> > ) ENGINE=InnoDB  DEFAULT CHARSET=latin1;
>
> > The categories:
>
> > CREATE TABLE kategoris (
> >  kategoriId int(10) unsigned NOT NULL AUTO_INCREMENT,
> >  kategoriNamn varchar(40) NOT NULL,
> >  PRIMARY KEY (kategoriId)
> > ) ENGINE=MyISAM  DEFAULT CHARSET=latin1;
>
> > and the table to connect categories and the records:
>
> > CREATE TABLE cvs (
> >  kategoriId int(10) unsigned NOT NULL,
> >  meritId int(10) unsigned NOT NULL,
> >  PRIMARY KEY (kategoriId,meritId)
> > ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
>
> > For now I have managed to produce a index view with the following:
>
> >  > /**
> >  * @property Cvs $Cvs
> >  */
>
> > class CvsController extends AppController {
>
> >    var $name = 'Cvs';
> >    var $helpers = array('Minify', 'Mailto');
>
> >    function index() {
>
> >        $this->layout = 'cv';
>
> >        $this->set('utbildning', $this->Cv->query("SELECT merits.ar,
> > merits.titel, merits.plats, merits.stad, merits.beskrivning FROM
> > merits JOIN cvs ON merits.meritId = cvs.meritId JOIN kategoris ON
> > cvs.kategoriId = kategoris.kategoriId WHERE kategoris.kategoriNamn =
> > 'Utbildning' ORDER BY merits.modifierad DESC;"));
> >    }
> > }
> > ?>
>
> > A simple SQL-query, because I know how to work them.
>
> > Now, I don't know how to write the models, so i can add the other
> > actions, add, edit, delete. After some researches, I think it has
> > something to do with (hasOne, hasMany, belongsTo) but would certainly
> > need some help.
>
> Yes, you should be following Cake's conventions so that you can take
> advantage of associations (hasOne, etc.). However, I'm goingto have to
> show you using english, simply because I'm unsure of the inflections.
> Sorry about that. Maybe someone else can adjust this to use your
> laguage.
>
> First thing, use "id" for the PK:
>
> CREATE TABLE merits (
>         id int(10) unsigned NOT NULL AUTO_INCREMENT,
>         ar varchar(20) DEFAULT NULL,
>         titel varchar(40) NOT NULL,
>         plats varchar(40) DEFAULT NULL,
>         stad varchar(40) DEFAULT NULL,
>         beskrivning text,
>         modifierad timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE
>         CURRENT_TIMESTAMP,
>         PRIMARY KEY (meritId)
> ) ENGINE=InnoDB  DEFAULT CHARSET=latin1;
>
> For this table, normally we would use "name" also, so that
> find('list') will work properly. To use "kategoriNamn" instead, you'll
> need to change the $displayField in the model definition:
>
> var $displayField = 'kategoriNamn';
>
> You /can/ also change the PK for the model to "kategoriId" but that's
> complicating things.
>
> CREATE TABLE kategoris (
>         id int(10) unsigned NOT NULL AUTO_INCREMENT,
>         kategoriNamn varchar(40) NOT NULL,
>         PRIMARY KEY (kategoriId)
> ) ENGINE=MyISAM  DEFAULT CHARSET=latin1;
>
> Normally, the join table name is made from the names ofthe two tables,
> "kategoris_merits" in this case. Then, column names are based on the
> singular tablename plus "_id". If your tables were "records" and
> "categories", your table would be:
>
> CREATE TABLE kategoris_merits (
>         category_d int(10) unsigned NOT NULL,
>         record_id int(10) unsigned NOT NULL,
>         UNIQUE(category_d, record_id)
> ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
>
> This is where the inflections fget confusing for me. You see that the
> column names are singular. I don't know how that would work for you.
>
> Note that you don't make a multiple-column PK. You can add a UNIQUE
> key, though, and, if you really want a PK, add an auto_increment
> column, like with any table.
>
> Once you have the tables set up, you then need to define the
> associations in the models. Because you've got a join table, I assume
> that you a Record can belong to more than one Category. In th

Re: Models, joins and forms

2010-07-22 Thread cricket
On Thu, Jul 22, 2010 at 10:36 AM, Joachim Nyqvist  wrote:
> Ok, I'm new to Cake, but not php. I don't know how to build my models
> for easy creation of add, edit and delete actions.
>
> I have three tables:
>
> The records:
>
> CREATE TABLE merits (
>  meritId int(10) unsigned NOT NULL AUTO_INCREMENT,
>  ar varchar(20) DEFAULT NULL,
>  titel varchar(40) NOT NULL,
>  plats varchar(40) DEFAULT NULL,
>  stad varchar(40) DEFAULT NULL,
>  beskrivning text,
>  modifierad timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE
> CURRENT_TIMESTAMP,
>  PRIMARY KEY (meritId)
> ) ENGINE=InnoDB  DEFAULT CHARSET=latin1;
>
> The categories:
>
> CREATE TABLE kategoris (
>  kategoriId int(10) unsigned NOT NULL AUTO_INCREMENT,
>  kategoriNamn varchar(40) NOT NULL,
>  PRIMARY KEY (kategoriId)
> ) ENGINE=MyISAM  DEFAULT CHARSET=latin1;
>
> and the table to connect categories and the records:
>
> CREATE TABLE cvs (
>  kategoriId int(10) unsigned NOT NULL,
>  meritId int(10) unsigned NOT NULL,
>  PRIMARY KEY (kategoriId,meritId)
> ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
>
> For now I have managed to produce a index view with the following:
>
>  /**
>  * @property Cvs $Cvs
>  */
>
> class CvsController extends AppController {
>
>    var $name = 'Cvs';
>    var $helpers = array('Minify', 'Mailto');
>
>    function index() {
>
>        $this->layout = 'cv';
>
>        $this->set('utbildning', $this->Cv->query("SELECT merits.ar,
> merits.titel, merits.plats, merits.stad, merits.beskrivning FROM
> merits JOIN cvs ON merits.meritId = cvs.meritId JOIN kategoris ON
> cvs.kategoriId = kategoris.kategoriId WHERE kategoris.kategoriNamn =
> 'Utbildning' ORDER BY merits.modifierad DESC;"));
>    }
> }
> ?>
>
> A simple SQL-query, because I know how to work them.
>
> Now, I don't know how to write the models, so i can add the other
> actions, add, edit, delete. After some researches, I think it has
> something to do with (hasOne, hasMany, belongsTo) but would certainly
> need some help.


Yes, you should be following Cake's conventions so that you can take
advantage of associations (hasOne, etc.). However, I'm goingto have to
show you using english, simply because I'm unsure of the inflections.
Sorry about that. Maybe someone else can adjust this to use your
laguage.

First thing, use "id" for the PK:

CREATE TABLE merits (
id int(10) unsigned NOT NULL AUTO_INCREMENT,
ar varchar(20) DEFAULT NULL,
titel varchar(40) NOT NULL,
plats varchar(40) DEFAULT NULL,
stad varchar(40) DEFAULT NULL,
beskrivning text,
modifierad timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE
CURRENT_TIMESTAMP,
PRIMARY KEY (meritId)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1;


For this table, normally we would use "name" also, so that
find('list') will work properly. To use "kategoriNamn" instead, you'll
need to change the $displayField in the model definition:

var $displayField = 'kategoriNamn';

You /can/ also change the PK for the model to "kategoriId" but that's
complicating things.

CREATE TABLE kategoris (
id int(10) unsigned NOT NULL AUTO_INCREMENT,
kategoriNamn varchar(40) NOT NULL,
PRIMARY KEY (kategoriId)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1;


Normally, the join table name is made from the names ofthe two tables,
"kategoris_merits" in this case. Then, column names are based on the
singular tablename plus "_id". If your tables were "records" and
"categories", your table would be:

CREATE TABLE kategoris_merits (
category_d int(10) unsigned NOT NULL,
record_id int(10) unsigned NOT NULL,
UNIQUE(category_d, record_id)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

This is where the inflections fget confusing for me. You see that the
column names are singular. I don't know how that would work for you.

Note that you don't make a multiple-column PK. You can add a UNIQUE
key, though, and, if you really want a PK, add an auto_increment
column, like with any table.


Once you have the tables set up, you then need to define the
associations in the models. Because you've got a join table, I assume
that you a Record can belong to more than one Category. In thatcase,
you need to set up HABTM associations in each model.

If a Record can only belong to a single Category, though, you should
drop the join table, add a category_id column to the records table,
and your assoc. would be:

Category hasMany Record
Record belongsTo Category


Again, I apologise for the lack of language-specific help. Perhaps all
this can be done without resorting to english names.

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

Models, joins and forms

2010-07-22 Thread Joachim Nyqvist
Ok, I'm new to Cake, but not php. I don't know how to build my models
for easy creation of add, edit and delete actions.

I have three tables:

The records:

CREATE TABLE merits (
  meritId int(10) unsigned NOT NULL AUTO_INCREMENT,
  ar varchar(20) DEFAULT NULL,
  titel varchar(40) NOT NULL,
  plats varchar(40) DEFAULT NULL,
  stad varchar(40) DEFAULT NULL,
  beskrivning text,
  modifierad timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE
CURRENT_TIMESTAMP,
  PRIMARY KEY (meritId)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1;

The categories:

CREATE TABLE kategoris (
  kategoriId int(10) unsigned NOT NULL AUTO_INCREMENT,
  kategoriNamn varchar(40) NOT NULL,
  PRIMARY KEY (kategoriId)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1;

and the table to connect categories and the records:

CREATE TABLE cvs (
  kategoriId int(10) unsigned NOT NULL,
  meritId int(10) unsigned NOT NULL,
  PRIMARY KEY (kategoriId,meritId)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

For now I have managed to produce a index view with the following:

layout = 'cv';

$this->set('utbildning', $this->Cv->query("SELECT merits.ar,
merits.titel, merits.plats, merits.stad, merits.beskrivning FROM
merits JOIN cvs ON merits.meritId = cvs.meritId JOIN kategoris ON
cvs.kategoriId = kategoris.kategoriId WHERE kategoris.kategoriNamn =
'Utbildning' ORDER BY merits.modifierad DESC;"));
}
}
?>

A simple SQL-query, because I know how to work them.

Now, I don't know how to write the models, so i can add the other
actions, add, edit, delete. After some researches, I think it has
something to do with (hasOne, hasMany, belongsTo) but would certainly
need some help.

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

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


Re: Multiple login forms submitting to one login action

2010-07-22 Thread cricket
On Wed, Jul 21, 2010 at 3:02 PM, tersmitten
 wrote:
> I'm having 2 login forms in my (cake) application. One on the home
> page (served by pages controller) and one in my user controller. The
> one from my user controller is working fine. But when I try to login
> from the homepage I get a blank page and I see in firebug I got a 404.
> The strange thing is that the session is setup OK.

Set debug to 2. When it's at 0, Cake throws a 404 when it encounters
an error. This is so it doesn't reveal them in production mode. You
probably have some unrelated error happening.

> It's looks like it has something to do with $this->Auth->autoRedirect
> = false (which is set in user controller beforeFilter()). What could
> be the problem?

That should go in AppController::beforeFilter()

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


Multiple login forms submitting to one login action

2010-07-21 Thread tersmitten
I'm having 2 login forms in my (cake) application. One on the home
page (served by pages controller) and one in my user controller. The
one from my user controller is working fine. But when I try to login
from the homepage I get a blank page and I see in firebug I got a 404.
The strange thing is that the session is setup OK.

It's looks like it has something to do with $this->Auth->autoRedirect
= false (which is set in user controller beforeFilter()). What could
be the 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: how to create forms

2010-07-20 Thread gabriel
Here a good tutorial for a contact form!

http://snook.ca/archives/cakephp/contact_form_cakephp

On Jul 19, 4:14 pm, amr_AJ  wrote:
> how to create forms

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 to create forms

2010-07-19 Thread Ed Propsner
http://book.cakephp.org/view/1384/Creating-Forms

On Mon, Jul 19, 2010 at 10:14 AM, amr_AJ  wrote:

> how to create forms
>
> 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.comFor
>  more options, visit this group at
> http://groups.google.com/group/cake-php?hl=en
>

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

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


how to create forms

2010-07-19 Thread amr_AJ
how to create forms

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: Forms/Model SQL Error

2010-06-30 Thread John Andersen
Please provide more information!
- Specify how the User model is defined together with the validation.

Question:
- is your controller named Register or Registers? In your form create
statement you name it Register!

Enjoy,
   John

On Jun 29, 10:50 pm, Nabeel  wrote:
> Hi all,
>
> I'm trying to create a form - I have a  Users model with some simple
> validation. I'm creating a form with:
>
> http://bin.cakephp.org/view/2134760139
>
> The output from this on the page is:
>
> http://bin.cakephp.org/view/220211324
>
> Hmm, that's not right. So I turn up debug:
>
> http://bin.cakephp.org/view/1647080842
>
> Not so pretty but basically:
>
> Warning (512): SQL Error: 1064: You have an error in your SQL syntax;
> check the manual that corresponds to your MySQL server version for the
> right syntax to use near 'entity' at line 1 [CORE/cake/libs/model/
> datasources/dbo_source.php, line 673]
>
> Showing where the form starts, and then:
>
> Warning (2): implode() [http://php.net/function.implode]: Invalid
> arguments passed [CORE/cake/libs/view/helper.php, line 643
> Warning (2): array_shift() expects parameter 1 to be array, boolean
> given [CORE/cake/libs/view/helper.php, line 597]
> Warning (2): array_map() [http://php.net/function.array-map]: Argument
> #2 should be an array [CORE/cake/libs/view/hel
> Warning (2): join() [http://php.net/function.join]: Invalid arguments
> passed [CORE/cake/libs/view/helper.php, line 598]
>
> When I remove the public $uses = array('User'); from my controller,
> there are no errors, and the fields show up properly. But then of
> course, I can't do any validation or saving of the data.
>
> Any ideas?
> 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


Forms/Model SQL Error

2010-06-29 Thread Nabeel
Hi all,

I'm trying to create a form - I have a  Users model with some simple
validation. I'm creating a form with:

http://bin.cakephp.org/view/2134760139

The output from this on the page is:

http://bin.cakephp.org/view/220211324

Hmm, that's not right. So I turn up debug:

http://bin.cakephp.org/view/1647080842

Not so pretty but basically:

Warning (512): SQL Error: 1064: You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version for the
right syntax to use near 'entity' at line 1 [CORE/cake/libs/model/
datasources/dbo_source.php, line 673]

Showing where the form starts, and then:

Warning (2): implode() [http://php.net/function.implode]: Invalid
arguments passed [CORE/cake/libs/view/helper.php, line 643
Warning (2): array_shift() expects parameter 1 to be array, boolean
given [CORE/cake/libs/view/helper.php, line 597]
Warning (2): array_map() [http://php.net/function.array-map]: Argument
#2 should be an array [CORE/cake/libs/view/hel
Warning (2): join() [http://php.net/function.join]: Invalid arguments
passed [CORE/cake/libs/view/helper.php, line 598]

When I remove the public $uses = array('User'); from my controller,
there are no errors, and the fields show up properly. But then of
course, I can't do any validation or saving of the data.

Any ideas?
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: forms

2010-06-22 Thread Andrei Mita
I don't see way it doesn't work. As Shaz suggested, double check if you have
the helper enabled.


On Tue, Jun 22, 2010 at 4:08 PM, Shaz  wrote:

> Try using $this->Form->create() instead of $form->create() in the
> view. Also make sure your form helper is enabled in the model.
>
> On Jun 22, 9:36 am, mirfan  wrote:
> > This is the script
> >
> >  $form->create("User",array('controller'=>'users','action'=>'register'));?>
> >
> > 
> > First Name *
> >  $form->input('User.first_name',
> > array('label'=>false,'class'=>'inputbox'));?>
> > Last Name *
> > input('User.last_name',
> > array('label'=>false,'class'=>'inputbox'));?>
> > Email *
> > input('User.email',
> > array('label'=>false,'class'=>'inputbox'));?>
> > Password *
> > input('User.password',
> > array('label'=>false,'div'=>false,'class'=>'inputbox'));?>
> > Confirm Password
> *
> > 
> >  id="password2"
> > name="password2" />
> > 
> >
> > input('User.group_id',
> > array('label'=>false,'type'=>'hidden','value'=>$type));?>
> >
> > Keywords*
> >  $form->input('Profile.keywords',
> > array('label'=>false,'div'=>'false','class'=>'inputbox'))?>
> >
> > Terms*
> > input('User.terms',
> > array('div'=>false,'label'=>false));?>
> > I accept the terms applied by SocialBidz
> >
> >  value="Register"
> > id="submitBtn3" />
> >
> > 
> >
> > Field with *
> are required
> > end();?>
> >
> > this is the output
> >
> > 
> >
> >  type="hidden" value="POST"
> > name="_method">id="ui-formular-error">
> > First Name *
> >  type="text"
> > id="UserFirstName" value="" maxlength="50" class="inputbox"
> > name="data[User][first_name]"> Last
> Name * > span>
> >  type="text"
> > id="UserLastName" value="" maxlength="50" class="inputbox"
> > name="data[User][last_name]">  Email
> * > label>
> >  type="text" id="UserEmail" value=""
> > maxlength="100" class="inputbox" name="data[User][email]">
> > Password *
> >  value="" class="inputbox"
> > name="data[User][password]">   Confirm
> Password * > span>
> > 
> >  id="password2"
> > class="inputbox">
> > 
> >
> >  value="" name="data[User]
> > [group_id]">
> > Keywords*
> >  id="ProfileKeywords" class="inputbox"
> > rows="6" cols="30" name="data[Profile][keywords]"> > div>
> > Terms*
> >  id="UserTerms_" name="data[User]
> > [terms]"> > name="data[User][terms]">  I accept the terms
> applied by SocialBidz
> >
> > 
> >
> >  id="submitBtn3"
> > value="Register">
> >
> > 
> >
> > Field with *
> are required
> > 
>
> 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.comFor
>  more options, visit this group at
> http://groups.google.com/group/cake-php?hl=en
>

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

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


  1   2   3   4   5   6   7   >