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

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

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

   
 ?php $customers = $this-requestAction('customers/add'); ?

div class=customers form
?php echo $this-Form-create('Customer'); ?



?php
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));
?
?php echo $this-Form-end($options); ?

/div



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.


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

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

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


  ?php $customers = $this-requestAction('customers/add'); ?
 
 div class=customers form
 ?php echo $this-Form-create('Customer'); ?
 
 
 
 ?php
 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));
 ?
 ?php echo $this-Form-end($options); ?
 
 /div



 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.




Adding image (png) icon in form-button element - please help.

2011-12-07 Thread Blues Clues
Hi:

I have a, hopefully, silly problem. Can you help ?

I have for Form-Button in my view that looks like this...

?php echo $form-button('Edit', array('class'=btnEdit,
'escape'=true, 'type'=button)); ?

Now, I would like to add a small img (png) before 'Edit' to make it
pretty.

?php echo $form-button($this-Html-image(myimg.png, array(alt
= Edit)).Edit, array('class'=btnEdit, 'escape'=true,
'type'=button)); ?

But this is simply generating a button like this with the text below
embed (that's what UI shows)

img src=/dev/134/img/myimg.png alt=Edit /Edit

 the HTML looks like this...

button type=button class=btnEditlt;img src=/jammer/cl134/img/
resetpasswd.png alt=Edit /gt;Edit/button

I can't seem to get this work...Can someone help me with this please?

I have a similar code elsewhere and this works great but I am trying
to use form helper elements this time and I am not making progress

button type=submit class=test name=test
?php echo $html-image(myimg.png);?
Login
/button

-BC

-- 
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: Adding image (png) icon in form-button element - please help.

2011-12-07 Thread euromark
why are you purposely setting 'escape'=true?
if you want to use html inside an element you are shooting yourself in
the foot this way.
it should rather by false then.


On 7 Dez., 21:10, Blues Clues bluesclu...@gmail.com wrote:
 Hi:

 I have a, hopefully, silly problem. Can you help ?

 I have for Form-Button in my view that looks like this...

 ?php echo $form-button('Edit', array('class'=btnEdit,
 'escape'=true, 'type'=button)); ?

 Now, I would like to add a small img (png) before 'Edit' to make it
 pretty.

 ?php echo $form-button($this-Html-image(myimg.png, array(alt
 = Edit)).Edit, array('class'=btnEdit, 'escape'=true,
 'type'=button)); ?

 But this is simply generating a button like this with the text below
 embed (that's what UI shows)

 img src=/dev/134/img/myimg.png alt=Edit /Edit

  the HTML looks like this...

 button type=button class=btnEditlt;img src=/jammer/cl134/img/
 resetpasswd.png alt=Edit /gt;Edit/button

 I can't seem to get this work...Can someone help me with this please?

 I have a similar code elsewhere and this works great but I am trying
 to use form helper elements this time and I am not making progress

     button type=submit class=test name=test
         ?php echo $html-image(myimg.png);?
         Login
     /button

 -BC

-- 
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: Adding image (png) icon in form-button element - please help.

2011-12-07 Thread Blues Clues
Yes, you are correct. I guess, I was being ignorant. Thanks. It works
now.

On Dec 7, 3:49 pm, euromark dereurom...@googlemail.com wrote:
 why are you purposely setting 'escape'=true?
 if you want to use html inside an element you are shooting yourself in
 the foot this way.
 it should rather by false then.

 On 7 Dez., 21:10, Blues Clues bluesclu...@gmail.com wrote:



  Hi:

  I have a, hopefully, silly problem. Can you help ?

  I have for Form-Button in my view that looks like this...

  ?php echo $form-button('Edit', array('class'=btnEdit,
  'escape'=true, 'type'=button)); ?

  Now, I would like to add a small img (png) before 'Edit' to make it
  pretty.

  ?php echo $form-button($this-Html-image(myimg.png, array(alt
  = Edit)).Edit, array('class'=btnEdit, 'escape'=true,
  'type'=button)); ?

  But this is simply generating a button like this with the text below
  embed (that's what UI shows)

  img src=/dev/134/img/myimg.png alt=Edit /Edit

   the HTML looks like this...

  button type=button class=btnEditlt;img src=/jammer/cl134/img/
  resetpasswd.png alt=Edit /gt;Edit/button

  I can't seem to get this work...Can someone help me with this please?

  I have a similar code elsewhere and this works great but I am trying
  to use form helper elements this time and I am not making progress

      button type=submit class=test name=test
          ?php echo $html-image(myimg.png);?
          Login
      /button

  -BC- Hide quoted text -

 - Show quoted text -

-- 
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: 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 make.cake.b...@gmail.com 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-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 make.cake.b...@gmail.com 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


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


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 make.cake.b...@gmail.com 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


ajax form field element null error

2009-02-20 Thread mrrezania


Hi, 
I'm trying to use the ajax-form code, as below:
 
?php echo $ajax-form(null,'post',array('update' =
'control'.$member['Member']['member_id'], 'url' =
array('controller'='comments', 'action'='add'))). \n;?
 
after page loaded I face this error in the Error Console:
Error: element is null
if (element._prototypeEventID) return element._prototypeEventID[0];
Source File: /prototype.js 
Line: 3847
 
If I remove the ajax line, the error is not there. Have I written it 
wrong?
 
Hope someone can help me.
 
Regrads,
Mohammadreza
-- 
View this message in context: 
http://n2.nabble.com/ajax-form-field-element-null-error-tp2360578p2360578.html
Sent from the CakePHP mailing list archive at Nabble.com.


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