Re: jQuery with Cake forms

2009-08-27 Thread Mike

Thanks a ton for the tip - this worked out great!

The only thing I'd want to warn other people about (just in case
someone else is following these same footsteps) is that the text input
appeared to be a normal, everyday text input until I clicked on it,
whereupon the DatePicker control nicely slid out & allowed me to use
it. :)

Thanks again!
--Mike

On Aug 26, 7:57 pm, Matt Curry  wrote:
> This one's pretty easy actually...Just set the input to be type text
> and attach the datepicker to the id of the input (not the div):
>
>  echo $form->input('field', array('type' => 'text'));
> ?>
>
> 
>   $(function(){
>     $('#ModelField').datepicker();
>   });
> 
>
> -Matthttp://www.pseudocoder.com
>
> On Aug 26, 10:02 pm, Mike  wrote:
>
>
>
> > Hello!
>
> > I'm looking to use jQuery with Cake, specifically with a form.  My
> > plan was to use a DatePicker  (http://docs.jquery.com/UI/Datepicker)
> > control instead of the default datetime drop-down menus, but it looks
> > like the easy approach (give the datetime div an id that jQuery's
> > DatePicker automagically replaces) doesn't seem to work.
> > Specifically, jQuery doesn't replace the Cake form elements (nevermind
> > stuff like feeding back into Cake's validation logic).  Also, I don't
> > want to use AJAX, just the UI control to make my otherwise normal form
> > easier to use.
>
> > I was thinking about hacking together some sort of custom, hidden form
> > elements to convey the datetime back to Cake, putting the DatePicker
> > on the page, and then having code in the 'onSubmit' to extract the
> > relevant info & stuff them into the hidden fields.  I got as far as
> > realizing that I'd need more code to auto-populate the control, plus
> > the uncertainty that Cake would actually use this info (even if I
> > named the form elements identically to the normal datetime stuff), and
> > realized how dodge-y this all sounded :)
>
> > So instead of throwing a lot of time into that first up, I wanted to
> > instead ask if there's a reasonable approach to this.  I *think* what
> > I want to do is replace a standard Cake $form->input field with my
> > own, but still have the auto-populate (and auto-validate) logic work.
>
> > Any ideas on ways to approach this would be appreciated.
>
> > Authoritative responses like "There's no way to do this without
> > rewriting parts of Cake/vast amounts of your own code" are also
> > appreciated (I'd rather find out this isn't possible & try something
> > else, instead of throwing tons of time into it and find that out on my
> > own :)  ).
>
> > Thanks!
> > --Mike
--~--~-~--~~~---~--~~
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: jQuery with Cake forms

2009-08-26 Thread Matt Curry

This one's pretty easy actually...Just set the input to be type text
and attach the datepicker to the id of the input (not the div):

input('field', array('type' => 'text'));
?>



  $(function(){
$('#ModelField').datepicker();
  });


-Matt
http://www.pseudocoder.com


On Aug 26, 10:02 pm, Mike  wrote:
> Hello!
>
> I'm looking to use jQuery with Cake, specifically with a form.  My
> plan was to use a DatePicker  (http://docs.jquery.com/UI/Datepicker)
> control instead of the default datetime drop-down menus, but it looks
> like the easy approach (give the datetime div an id that jQuery's
> DatePicker automagically replaces) doesn't seem to work.
> Specifically, jQuery doesn't replace the Cake form elements (nevermind
> stuff like feeding back into Cake's validation logic).  Also, I don't
> want to use AJAX, just the UI control to make my otherwise normal form
> easier to use.
>
> I was thinking about hacking together some sort of custom, hidden form
> elements to convey the datetime back to Cake, putting the DatePicker
> on the page, and then having code in the 'onSubmit' to extract the
> relevant info & stuff them into the hidden fields.  I got as far as
> realizing that I'd need more code to auto-populate the control, plus
> the uncertainty that Cake would actually use this info (even if I
> named the form elements identically to the normal datetime stuff), and
> realized how dodge-y this all sounded :)
>
> So instead of throwing a lot of time into that first up, I wanted to
> instead ask if there's a reasonable approach to this.  I *think* what
> I want to do is replace a standard Cake $form->input field with my
> own, but still have the auto-populate (and auto-validate) logic work.
>
> Any ideas on ways to approach this would be appreciated.
>
> Authoritative responses like "There's no way to do this without
> rewriting parts of Cake/vast amounts of your own code" are also
> appreciated (I'd rather find out this isn't possible & try something
> else, instead of throwing tons of time into it and find that out on my
> own :)  ).
>
> Thanks!
> --Mike
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



jQuery with Cake forms

2009-08-26 Thread Mike

Hello!

I'm looking to use jQuery with Cake, specifically with a form.  My
plan was to use a DatePicker  (http://docs.jquery.com/UI/Datepicker)
control instead of the default datetime drop-down menus, but it looks
like the easy approach (give the datetime div an id that jQuery's
DatePicker automagically replaces) doesn't seem to work.
Specifically, jQuery doesn't replace the Cake form elements (nevermind
stuff like feeding back into Cake's validation logic).  Also, I don't
want to use AJAX, just the UI control to make my otherwise normal form
easier to use.

I was thinking about hacking together some sort of custom, hidden form
elements to convey the datetime back to Cake, putting the DatePicker
on the page, and then having code in the 'onSubmit' to extract the
relevant info & stuff them into the hidden fields.  I got as far as
realizing that I'd need more code to auto-populate the control, plus
the uncertainty that Cake would actually use this info (even if I
named the form elements identically to the normal datetime stuff), and
realized how dodge-y this all sounded :)

So instead of throwing a lot of time into that first up, I wanted to
instead ask if there's a reasonable approach to this.  I *think* what
I want to do is replace a standard Cake $form->input field with my
own, but still have the auto-populate (and auto-validate) logic work.

Any ideas on ways to approach this would be appreciated.

Authoritative responses like "There's no way to do this without
rewriting parts of Cake/vast amounts of your own code" are also
appreciated (I'd rather find out this isn't possible & try something
else, instead of throwing tons of time into it and find that out on my
own :)  ).

Thanks!
--Mike
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---