Re: Problem with Automagic Form Elements

2008-12-10 Thread grigri

I don't know if this is any help, but I got the mootools calendar from
[http://www.electricprism.com/aeron/calendar/] running very easily.

(Using mootools1.2.1; need calendar.compat.js from the above link)

This is all the code that is necessary for unobtrusive integration:

(I agree that the `obj` construction is odd... the parameters are done
in a wierd way)

[code also posted here: http://bin.cakephp.org/view/980647196 for
clarity]

create('Article');
echo $form->inputs();
echo $form->end('Submit');

// Add css and js
$javascript->link('calendar.compat', false);
$html->css('calendar', null, array(), false);

// Add code to transform all datetime and date fields
echo $javascript->codeBlock(trim("
window.addEvent('domready', function() {
$$('form .datetime', 'form .date').each(function(div) {
var last = null;
var y = div.getElement('select[name*=year]');  if (!last ||
y.offsetLeft > last.offsetLeft) last=y;
var m = div.getElement('select[name*=month]'); if (!last ||
m.offsetLeft > last.offsetLeft) last=m;
var d = div.getElement('select[name*=day]');   if (!last ||
d.offsetLeft > last.offsetLeft) last=d;
if (y && m && d) {
var obj = {}; obj[last.id] = {}; 
obj[last.id][y.id]='Y'; obj
[last.id][m.id]='m'; obj[last.id][d.id]='d';
new Calendar(obj);
}
});
});
"));

?>

hth
grigri

On Dec 10, 11:06 am, Pillow <[EMAIL PROTECTED]> wrote:
> OK.. Update - Problem resolved!
> It was my bad, I had put plurals
> var $uses = array('Orders', 'Businesses');
> in the controller instead of singular!
>
> Thanks very much for your help, sorry it was a waste of your time!
>
> I would however like to get the 'unobtrusive date picker' to work - if
> anyone has any advice as to how the instructions in the article above
> can be adapted for 1.2 that would be a real bonus.
>
> Kindest Regards
> Ed

On Dec 10, 11:06 am, Pillow <[EMAIL PROTECTED]> wrote:
> OK.. Update - Problem resolved!
> It was my bad, I had put plurals
> var $uses = array('Orders', 'Businesses');
> in the controller instead of singular!
>
> Thanks very much for your help, sorry it was a waste of your time!
>
> I would however like to get the 'unobtrusive date picker' to work - if
> anyone has any advice as to how the instructions in the article above
> can be adapted for 1.2 that would be a real bonus.
>
> Kindest Regards
> Ed
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Problem with Automagic Form Elements

2008-12-10 Thread WebbedIT

> Thanks very much for your help, sorry it was a waste of your time!

You're very welcome, it was not a waste of my time if my ramblings
made you think a bit deeper as to why Cake was unable to perform it's
magic.!

And if anyone else makes the same mistake in the future they may come
across this post and not have to spend as much time tearing their hair
out ;)

Paul.
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Problem with Automagic Form Elements

2008-12-10 Thread Pillow

OK.. Update - Problem resolved!
It was my bad, I had put plurals
var $uses = array('Orders', 'Businesses');
in the controller instead of singular!

Thanks very much for your help, sorry it was a waste of your time!

I would however like to get the 'unobtrusive date picker' to work - if
anyone has any advice as to how the instructions in the article above
can be adapted for 1.2 that would be a real bonus.

Kindest Regards
Ed
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Problem with Automagic Form Elements

2008-12-10 Thread WebbedIT

Well unfortunately .. that's got me totally  flummoxed!

Everything looks fine, and as such it must be something to do with
Cake not being able to properly interrogate the table and therefore it
does not know the type of each field.

Anyone else got any ideas as to why this is happening?
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Problem with Automagic Form Elements

2008-12-10 Thread Pillow

Ok, sure.

The table is as follows:

CREATE TABLE `orders` (
  `id` int(11) NOT NULL auto_increment,
  `order_date` datetime NOT NULL default '-00-00 00:00:00',
  `order_total` float NOT NULL default '0',
  `business_id` int(11) NOT NULL default '0',
  `package_id` int(11) default NULL,
  `option_id` int(11) default NULL,
  `advert_start_date` date NOT NULL default '-00-00',
  `advert_end_date` date NOT NULL default '-00-00',
  `payment_received` tinyint(1) NOT NULL default '0',
  `status` varchar(50) NOT NULL default '',
  `ip_address` varchar(20) NOT NULL default '',
  `op_description_box` tinyint(1) NOT NULL default '0',
  `op_long_description` tinyint(1) NOT NULL default '0',
  `op_main_image` tinyint(1) NOT NULL default '0',
  `op_link_to_company` tinyint(1) NOT NULL default '0',
  `op_images` smallint(6) default '0',
  `op_thumbnail_image` tinyint(1) NOT NULL default '0',
  `op_large_banner` tinyint(1) NOT NULL default '0',
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;


And the view comes out like this:


create('Order');?>


input('order_date');
echo $form->input('order_total');
echo $form->input('business_id');
echo $form->input('package_id');
echo $form->input('option_id');
echo $form->input('advert_start_date');
echo $form->input('advert_end_date');
echo $form->input('payment_received');
echo $form->input('status');
//echo $form->input('ip_address');
echo $form->input('op_description_box');
echo $form->input('op_long_description');
echo $form->input('op_main_image');
echo $form->input('op_link_to_company');
echo $form->input('op_images');
echo $form->input('op_thumbnail_image');
echo $form->input('op_large_banner');
?>

end('Submit');?>


I also note that the tinyint/checkbox fields are not picked up by the
automagic either...
Hope you are able to shed some light. I apologise in advance if I have
missed something obvious!

Cheers
Ed
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Problem with Automagic Form Elements

2008-12-10 Thread WebbedIT

> However, I am still stuck with the problem.
> The fields are definitely named correctly. The table for which the
> automagic works and the table for which it does not were created using
> the same SQL script. The view was created using bake. I am unable to
> determine the reason for this anomaly.

$form->input does it's magic fine, therefore I can only assume that
there has to be something going wrong in the baked views/tables.

Can you post a dump of your tables and the view code so we can try and
figure this out?  It's really hard to accurately diagnose a fault we
can't see.
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Problem with Automagic Form Elements

2008-12-10 Thread Pillow

Thank you for your advice.
However, I am still stuck with the problem.
The fields are definitely named correctly. The table for which the
automagic works and the table for which it does not were created using
the same SQL script. The view was created using bake. I am unable to
determine the reason for this anomaly.

I would be very grateful for any further input on this.

I have also investigated the acrticle by Marcel Manning at
http://bakery.cakephp.org/articles/view/using-the-unobtrusive-date-picker-widget-in-cakephp
with a view to implementing this. However, the information is out of
date and some files referred to in the article do not exist in CakePHP
1.2 (i.e. default.thtml). There are some comments at the bottom but
they are not at all helpful.

If someone has the aforementioned date picker widget working in 1.2
I'm sure many others as well as I would appreciate if the article was
updated to include suitable instructions.

Thanks again and kind regards.
Ed

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Problem with Automagic Form Elements

2008-12-09 Thread WebbedIT

> I think that in order to work you need to specify the model name in
> $form->create(), you should check that the form with no "formating"
> have the right model. And if it belongs to a form for another model, I
> think you'll have to added the type parameter to the input by hand.

Don't think this is the case, for me the following 'automagic' form
fields render fine within the same form:

echo $form->create('Staff');
echo $form->input('Staff.date_enquired', array('empty' => true));
echo $form->input('Person.dob', array('empty' => true));

The array('empty' => true) allows you to supply a blank date, which
actually gets added as a NULL value if any of the three select lists
are left blank.

You sure you have named the fields correctly as the 'automagic' should
interrogate the table and if it comes across a DATE field type it
should give you the three select lists.


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Problem with Automagic Form Elements

2008-12-09 Thread jmn2k1

I think that in order to work you need to specify the model name in
$form->create(), you should check that the form with no "formating"
have the right model. And if it belongs to a form for another model, I
think you'll have to added the type parameter to the input by hand.

JmN

On 9 dic, 13:57, Pillow <[EMAIL PROTECTED]> wrote:
> Dear Cake People,
>
> I hope you can assist with this confusing issue.
> I am building an application in which several tables contain
> advert_start_date and advert_end_date fields. In MySQL they are set as
> the DATE type.
> The problem I am experiencing is that in the forms for one controller,
> the input is 'automagically' created as drop-down selection boxes for
> year, month, day. However, in other controllers only a simple text box
> is rendered.
> I cannot figure out why the forms are produced differently. The field
> names are identical, the data types identical. The views have just all
> been baked at this stage and contain no specific formatting details.
> Are there any other factors which could be affecting the 'automagic'
> behaviour?
> Thanks in advance,
> Ed

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Problem with Automagic Form Elements

2008-12-09 Thread Pillow

Dear Cake People,

I hope you can assist with this confusing issue.
I am building an application in which several tables contain
advert_start_date and advert_end_date fields. In MySQL they are set as
the DATE type.
The problem I am experiencing is that in the forms for one controller,
the input is 'automagically' created as drop-down selection boxes for
year, month, day. However, in other controllers only a simple text box
is rendered.
I cannot figure out why the forms are produced differently. The field
names are identical, the data types identical. The views have just all
been baked at this stage and contain no specific formatting details.
Are there any other factors which could be affecting the 'automagic'
behaviour?
Thanks in advance,
Ed

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---