Re: Form in Element instead of View

2014-08-06 Thread José Lorenzo
'customer' is not an HTTP method, maybe you are confusing the is('post') as 
if it were a Post model and not a POST request. Just change that if to:

 if($this->request->is('post')) {

On Wednesday, August 6, 2014 12:19:56 PM UTC+2, Jovan Chee Nanić wrote:
>
> I have to do one page web application in cakePHP. I have template where 
> are put all divs and from jQuery then show or hidden appropriate div. I 
> have two div with forms to store some data in db. I crated elements for my 
> div-s, and then in my layout, in each div i put 
>
> < ? php echo $this->element('register'); ?>
>
> I created form in element, a same way in view.
>
>
>  requestAction('customers/add'); ?>
> 
> 
> Form->create('Customer'); ?>
> 
> 
> 
>  echo $this->Form->input('salutation', array(
> 'options' => array('Mr' => 'Mr', 'Mrs' => 'Mrs', 
> 'Ms' => 'Ms')
> ));
> echo $this->Form->input('firstname', array('required' => true
> ));
> echo $this->Form->input('lastname', array('required' 
> => true));
> echo $this->Form->input('street', array('required' => true));
> echo $this->Form->input('zip_city', array('required' 
> => true));
> echo $this->Form->input('country', array('required' => 
> true));
> echo $this->Form->input('phone', array('required' => 
> true));
> echo $this->Form->input('email', array('required' => 
> true));
> ?>
> Form->end($options); ?>
> 
> 
>
>
>
> My controller for adding data in db:
>
> 
> public function add(){
> if($this->request->is('customer')) {
> $this->Customer->create();
> if($this->Customer->save($this->request->data)){
> $this->Session->setFlash('Register successiful');
> }
> $this->Session->setFlash('Unable to register!');
> }
> }
>
>
>
> I think that is my problem in this line: 
>
> if($this->request->is('customer')) {
>
>
>
> If I remove if-statement, I succedd to store data in table, but stored and 
> more blank rows.
>
> I appreciate every suggestion. 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/d/optout.


Form in Element instead of View

2014-08-06 Thread Jovan Chee Nanić
I have to do one page web application in cakePHP. I have template where are 
put all divs and from jQuery then show or hidden appropriate div. I have 
two div with forms to store some data in db. I crated elements for my 
div-s, and then in my layout, in each div i put 

< ? php echo $this->element('register'); ?>

I created form in element, a same way in view.

   
 requestAction('customers/add'); ?>


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



Form->input('salutation', array(
'options' => array('Mr' => 'Mr', 'Mrs' => 'Mrs', 
'Ms' => 'Ms')
));
echo $this->Form->input('firstname', array('required' => true));
echo $this->Form->input('lastname', array('required' => 
true));
echo $this->Form->input('street', array('required' => true));
echo $this->Form->input('zip_city', array('required' => 
true));
echo $this->Form->input('country', array('required' => 
true));
echo $this->Form->input('phone', array('required' => 
true));
echo $this->Form->input('email', array('required' => 
true));
?>
Form->end($options); ?>





My controller for adding data in db:


public function add(){
if($this->request->is('customer')) {
$this->Customer->create();
if($this->Customer->save($this->request->data)){
$this->Session->setFlash('Register successiful');
}
$this->Session->setFlash('Unable to register!');
}
}



I think that is my problem in this line: 

if($this->request->is('customer')) {



If I remove if-statement, I succedd to store data in table, but stored and 
more blank rows.

I appreciate every suggestion. 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/d/optout.


Population values in a form in element view

2012-09-05 Thread DiabloGeto


>
> Hi All,
>
> I have a Form which contains only checkbox with different Attributes.I 
> have  a array with key value pair of name of the  input field and check box 
> values and i have passed the same to the view. I am using that form in the 
> another view as a element however as a element it doesn't populates values 
> by itself.
>
 

> How can i populate the checked to the form by the array or i have to check 
> them one by one for every field.  
>

I created view for the function  to check is it working in its own view, 
and it is populating it automatically,  Can some one tell where i have the 
problem.
do i need to set the array variable in the parent action.? 

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




Re: Form in element

2010-02-04 Thread John Andersen
The way I would solve it, is probably not a CakePHP thing, but it
would work for me :)

I would make the signup form invoke the same method that the current
page renders from, but with the signup submit button named "doSignup".

In the AppController I would add a method to process the signup and
invoke it from the beforeFilter method (or the form action method) as:

[code]
if ( isset($this->params['form']) and !empty($this->params['form']) )
{
   foreach( $this->params['form'] as $action => $actionValue ) {
  switch( $action ) {
 case 'doSignup" :
 ... invoke signup processing method ...
 ...
  }
   }
}
[/code]

This should ensure that any validation errors are returned together
with the view and your flash message.

Ok, have to admit, the solution is not tested, as my issue was a
little different than yours, but the idea is the same.
Enjoy,
   John


On Feb 4, 6:41 pm, "Dave"  wrote:
> Almost correct in assuming.
>
> Every page has the sign-up.
>
> PageA
> PageB
> PageZ and everything in between.
>
> So sign up click and request goes to newsletters_controler / add so if it
> saves I have redirect referrer so presto back to where I started. If not I
> get the session flash error message back where I was but the form has no
> errors hilighted saying why failed.
>
> -Original Message-
> From: cake-php@googlegroups.com [mailto:cake-...@googlegroups.com] On Behalf
>
> Of John Andersen
> Sent: February-04-10 4:16 AM
> To: CakePHP
> Subject: Re: Form in element
>
> If I understand you correctly Dave, then you have a page A on which is a
> newsletter signup form. When the user submits an e-mail address, you want to
> present the user to page B if the e-mail address is valid. If the e-mail
> address is not valid, stay on page A. Correct?
>
> Assuming I am correct :) ... in the controller receiving the newsletter
> signup submit - if the e-mail address is valid, redirect the user to page B.
> If the e-mail address is not valid, redirect the user to page A, using
> $this->referer() as the redirect address.
>
> Enjoy,
>    John
[snip]

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: Form in element

2010-02-04 Thread Dave
 
Almost correct in assuming.

Every page has the sign-up.

PageA
PageB
PageZ and everything in between.

So sign up click and request goes to newsletters_controler / add so if it
saves I have redirect referrer so presto back to where I started. If not I
get the session flash error message back where I was but the form has no
errors hilighted saying why failed.


-Original Message-
From: cake-php@googlegroups.com [mailto:cake-...@googlegroups.com] On Behalf
Of John Andersen
Sent: February-04-10 4:16 AM
To: CakePHP
Subject: Re: Form in element

If I understand you correctly Dave, then you have a page A on which is a
newsletter signup form. When the user submits an e-mail address, you want to
present the user to page B if the e-mail address is valid. If the e-mail
address is not valid, stay on page A. Correct?

Assuming I am correct :) ... in the controller receiving the newsletter
signup submit - if the e-mail address is valid, redirect the user to page B.
If the e-mail address is not valid, redirect the user to page A, using
$this->referer() as the redirect address.

Enjoy,
   John

On Feb 4, 4:03 am, "Dave"  wrote:
> I have a form in an element and wondering how to return back to the 
> page it was sent from if its successful or if there are errors display 
> the errors on the same page.
>
> Basically its a side menu and at the bottom a mini form to signup for 
> newsletter which is on every page. So if the user adds their email and 
> saved success im still on that page...not newsletters/index and if not 
> successful same page but with errors.
> (not using ajax and not an option)
>
> Thanks,
>
> Dave

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 
cake-php+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: Form in element

2010-02-03 Thread John Andersen
If I understand you correctly Dave, then you have a page A on which is
a newsletter signup form. When the user submits an e-mail address, you
want to present the user to page B if the e-mail address is valid. If
the e-mail address is not valid, stay on page A. Correct?

Assuming I am correct :) ... in the controller receiving the
newsletter signup submit - if the e-mail address is valid, redirect
the user to page B. If the e-mail address is not valid, redirect the
user to page A, using $this->referer() as the redirect address.

Enjoy,
   John

On Feb 4, 4:03 am, "Dave"  wrote:
> I have a form in an element and wondering how to return back to the page it
> was sent from if its successful or if there are errors display the errors on
> the same page.
>
> Basically its a side menu and at the bottom a mini form to signup for
> newsletter which is on every page. So if the user adds their email and saved
> success im still on that page...not newsletters/index and if not successful
> same page but with errors.
> (not using ajax and not an option)
>
> Thanks,
>
> Dave

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


Form in element

2010-02-03 Thread Dave
I have a form in an element and wondering how to return back to the page it
was sent from if its successful or if there are errors display the errors on
the same page.
 
Basically its a side menu and at the bottom a mini form to signup for
newsletter which is on every page. So if the user adds their email and saved
success im still on that page...not newsletters/index and if not successful
same page but with errors.
(not using ajax and not an option)
 
Thanks,
 
Dave

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