Thanks Yusuf, and Dardo.

I am using another page to inject a value into the disabled form text
input box, which works. However I guess Cake strips it out on
submission. I just thought of another idea after Yusuf posted, I could
have it disabled until they click submit and then quickly enable it at
the last second. I just don't want the user to be able to change the
value of the text input box except through my other form control that
put the value there. Would also be handy if there was a some
setEditable=false type option to it, may be there is, I'll have to
look.

On Jan 22, 7:08 pm, Yusuf Widiyatmono <wmo...@yahoo.com> wrote:
> If the value of disabled form element could changed dynamically (maybe you 
> have some lil process on your view), maybe you need some little javascript 
> script here...
>
> <script>
> function test(){
>     document.ItemEdit.getElementById('ItemQuantytyHid').value = 
> document.ItemEdit.getElementById('ItemQuantyty').value;}
>
> </script>
>
> print $form->create('Item', 
> array("action"=>"edit","onsubmit"=>"javascript:test();"));
> print $form->input('Item.quantity', array("label"=>"Quantity", 
> "disabled"=>"disabled");
> print $form->hidden('Item.quantityHid');
> print $form->end('Submit');
>
> and then in your controller
> you have to do this
>
> if(!empty($this->data)){
>     $this->data['Item']['quantyty] = $this->data['Item']['quantytyHid];
>     $this->Item->save($this->data['Item']);
>
> }
>
> i have not tested this yet :P, but i think you could figure it out :)...
>
> hope this help..
>
> ________________________________
> From: Dardo Sordi Bogado <dardoso...@gmail.com>
> To: cake-php@googlegroups.com
> Sent: Friday, January 23, 2009 9:39:28 AM
> Subject: Re: How to submit form elements that are disabled?
>
> > I want to have a form text input get submitted, but also want it to be
> > disabled on display.
>
> Fromhttp://www.w3.org/TR/html401/interact/forms.html#h-17.12:
>
> ...the INPUT element is disabled. Therefore, it cannot receive user
> input nor will its value be submitted with the form.
>
> you also need to add the field as hidden, so it's value will be posted.
>
>
>
> > Eg. $form->input('frmInputQuantity', array('label'=>'Quantity:',
> > 'disabled'=>'disabled'));
>
> > This does not get submitted into $this->data. How can I change what
> > gets posted to $this->data with the form helper?- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to