Another solution I use is:
The fields which should be shown but not changeable get the attribure
"readojnly" and a cssclass which marks them as readonly:
Form:
echo $form->input('foo',array('type'=>'text', 'readonly' => 'true',
'class' => 'readonlyclass'));
CSS:
input.readonlyclass{
clear: both;
display:block;
font-size: 12px;
font-family: inherit;
border-width:1px;
border-color:#CCCCCC;
border-style:solid;
color: #777777;
}
Hope that helps!
Anja
-----Ursprüngliche Nachricht-----
Von: [email protected] [mailto:[EMAIL PROTECTED] Im Auftrag von
thatsgreat2345
Gesendet: Sonntag, 16. November 2008 19:32
An: CakePHP
Betreff: Re: Edit just one field with form
Why are you just trying to save one field, all the others going null are
because you don't load the $this->data array when you save it with anything for
those fields and you probably set not default when you created the fields in
your database, so they just assume null as default. I'm just really curious as
to how you have your fields setup to where you are only saving one field out of
10. However you said edit, so if you are trying to save for an existing row
you can do something like this.
$this->Model->id = row id;
$this->Model->saveField('FieldName','New Data');
On Nov 16, 9:46 am, jer <[EMAIL PROTECTED]> wrote:
> I am total newbie with cakephp, first few days have been total
> struggling. I have mysql table with 10 fields. I try to edit one text
> field with form, but every time I submit form, all other fields are
> set to null. Only field in form survives. Is there any tutorials about
> this or can someone help me?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---