Re: requestAction, modularity and multiple forms in one view

2007-06-26 Thread abba bryant


I have a variety of forms in a cms I am developing on one page. I use a
hidden form field ( I.E. If I was adding an image I would use a
$form->input( "Image.AddImage", array( "type"=>"hidden", "value"=>"1")); )

Then my controller ( typically an action named "manage" checks to see if
$this->data['Image']['AddImage'] is set to 1 / true and then process the
form as usual with if( $this->Image->save( $this->data ) ) ...

Works fine for me. The form will re-render the "manage" view with the errors
for the model as expected. Is what you need somehow more complicated?


willi-3 wrote:
> 
> 
> Push :-)
> 
> 
> > 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/requestAction%2C-modularity-and-multiple-forms-in-one-view-tf3797544.html#a11318680
Sent from the CakePHP mailing list archive at Nabble.com.


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



Re: requestAction, modularity and multiple forms in one view

2007-06-22 Thread R. Rajesh Jeba Anbiah

On Jun 22, 12:40 pm, Vincent <[EMAIL PROTECTED]> wrote:
> Hello -
>
> Did you ever get some answers on that. I have the same problem. I have
> 2 forms on my page and I am not sure how to manage them!
   

   Not tested, but look for the 'model' option in $form->create().

Something like this might work:
1. controller/action:
   $this->Model1->save($this->data);
   $this->Model2->save($this->data);

2. action.ctp:
  $form->create(array('model'=>'Model1')) //it should create form
inputs with ['Model1'] key
blah
  $form->end()

  $form->create(array('model'=>'Model2'))
blah
  $form->end()


--
  
Email: rrjanbiah-at-Y!comBlog: http://rajeshanbiah.blogspot.com/


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



Re: requestAction, modularity and multiple forms in one view

2007-06-22 Thread Vincent

Hello -

Did you ever get some answers on that. I have the same problem. I have
2 forms on my page and I am not sure how to manage them!

-V
willi wrote:
> Hi there!
>
> I'am very impressed about the huge capabilities of CakePHP and about
> to create a bigger application after playing around and figuring out,
> how things go.
>
> Now I'am a little confused, how to create things like multiple forms
> (with a dedicated model) in one view.
>
> I have two controllers: categories and images, with coresponding
> models and views, each controller with index/list/add/edit/delete
> functions.
>
> I want to have a view, that displays the categories/add form, the
> images/list table and the images/add form on one page. I did this,
> using the requestAction method in the images/index view like this:
>
> requestAction("/categories/
> add",array("return"=>true)); ?>
> requestAction("/images/add",array("return"=>true)); ?
> >
> (The images/list ist called by the images/index method)
>
> No problem so far.
>
> But now i want to do some validations and the error messages,
> depending on which form was submitted, should be displayed in the same
> view - no dedicated errorpage - everything in only this one view or
> one page if you want.
>
> I did something like this for the categories and images controller:
>
>   function add() {
>   if(!empty($this->data)) {
>   $this->cleanUpFields();
>   $this->Category->create();
>   if($this->Category->save($this->data)) {
>   $this->Session->setFlash('Success!');
>   $this->redirect('../images/index');
>   exit();
>   } else {
>   $this->Session->setFlash('Error!');
>   $this->render('../images/index');
>   }
>   }
>   }
>
> But I get no error messages and the forms were not populated.
>
> When I use $this->render();
>
> instead, I get errormessages, the form will be populated, but I only
> get the add-view - shure ...
>
> To cut a long story short: How do I handle the output of multiple
> forms in one view in an elegant way!?
>
> Thank you in advance!
>
> Willi


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



Re: requestAction, modularity and multiple forms in one view

2007-05-23 Thread willi

Push :-)


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



requestAction, modularity and multiple forms in one view

2007-05-22 Thread willi

Hi there!

I'am very impressed about the huge capabilities of CakePHP and about
to create a bigger application after playing around and figuring out,
how things go.

Now I'am a little confused, how to create things like multiple forms
(with a dedicated model) in one view.

I have two controllers: categories and images, with coresponding
models and views, each controller with index/list/add/edit/delete
functions.

I want to have a view, that displays the categories/add form, the
images/list table and the images/add form on one page. I did this,
using the requestAction method in the images/index view like this:

requestAction("/categories/
add",array("return"=>true)); ?>
requestAction("/images/add",array("return"=>true)); ?
>
(The images/list ist called by the images/index method)

No problem so far.

But now i want to do some validations and the error messages,
depending on which form was submitted, should be displayed in the same
view - no dedicated errorpage - everything in only this one view or
one page if you want.

I did something like this for the categories and images controller:

function add() {
if(!empty($this->data)) {
$this->cleanUpFields();
$this->Category->create();
if($this->Category->save($this->data)) {
$this->Session->setFlash('Success!');
$this->redirect('../images/index');
exit();
} else {
$this->Session->setFlash('Error!');
$this->render('../images/index');
}
}
}

But I get no error messages and the forms were not populated.

When I use $this->render();

instead, I get errormessages, the form will be populated, but I only
get the add-view - shure ...

To cut a long story short: How do I handle the output of multiple
forms in one view in an elegant way!?

Thank you in advance!

Willi


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