21298 Posts in 5735 Topics by 2603 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 2295 Views |
-
TextField Readonly

4 May 2009 at 11:03pm
I'm trying to set a textfield readonly.
I see in the documentation that I can set a TextField to readonly, however how is this implemented?
I have a custom form, but where do I put the readonly part for the field I want to make readonly?
function Form() {
return new Form($this, "Form", new FieldSet(// List your fields here
new EmailField("Email", "Email address"),
new PasswordField("Password", "Password"),
new TextField("FirstName", "First name"),
new TextField("LastName", "Last name"),
new TextField("Phone", "Phone"),
new TextField("Company", "Company/Hospital"),
new TextField("Address1", "Address 1"),
new TextField("Address2", "Address 2"),
new TextField("City", "City"),
new TextField("State", "State"),
new TextField("Zip", "Zip"),
new TextField("Country", "Country"),
new TextField("IPAdress","IPAddress",$_SERVER['REMOTE_ADDR'])
), new FieldSet(
// List the action buttons here
new FormAction("SignupAction", "Register")), new RequiredFields(
// List the required fields here: "Email", "FirstName"
"Email", "Password", "FirstName", "LastName", "Phone", "Company", "Address1", "City", "State", "Zip", "Country"));
} -
Re: TextField Readonly

4 May 2009 at 11:47pm Last edited: 4 May 2009 11:48pm
Hmm, yes nothing in the Docs on the usage of this.
I did find this inherited method however:
So maybe construct your field (I assume it's the IP field) seperately and try this before the new form declaration:
function Form() {
$IpField = new TextField("IPAdress","IPAddress",$_SERVER['REMOTE_ADDR']) ;
$IpField->setReadonly(true);return new Form($this, "Form", new FieldSet(
// List your fields here
new EmailField("Email", "Email address"),
new PasswordField("Password", "Password"),
new TextField("FirstName", "First name"),
new TextField("LastName", "Last name"),
new TextField("Phone", "Phone"),
new TextField("Company", "Company/Hospital"),
new TextField("Address1", "Address 1"),
new TextField("Address2", "Address 2"),
new TextField("City", "City"),
new TextField("State", "State"),
new TextField("Zip", "Zip"),
new TextField("Country", "Country"),
$IpField.......
Worth a stab
Aaron
-
Re: TextField Readonly

5 May 2009 at 12:35am
Double-A-Ron,
I seriously need to take a class on php5 functions and classes. I lack some serious knowledge that would go a long way in working with SS.
Thanks for the inside.
I certainly got the IPAddress to show up (easy) but would you expect the field to still be editable? I can erase the ip address.
I'm testing now to see if the IPField still comes across in the email.
Thanks again,
Terry
-
Re: TextField Readonly

5 May 2009 at 8:06am
Did you try making it a readOnlyField rather than use my code above?
-
Re: TextField Readonly

5 May 2009 at 3:25pm
Double-A-Ron,
One million thank you's....That did it. I did the following:
new ReadonlyField("IPAddress","IPAddress",$_SERVER['REMOTE_ADDR'])
Worked perfectly...
Thanks again,
Terry
| 2295 Views | ||
|
Page:
1
|
Go to Top |


