Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Form Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Adding visitor IP capture to User Forms


Go to End


2457 Views

Avatar
raZbi

Community Member, 11 Posts

29 April 2010 at 11:25pm

Hi,

Trying to capture IP address of visitor on form submission. Have added hidden field, called 'IPaddreess' to form, but stucked with applying any value to that field. Here's what i'm trying to add to UserDefinedForm.php:

if($submittedField->Name == 'IPaddress') { 
$submittedField->Value = 'Test';	
}

Either code is wrong, or i'm applying it at the wrong place, have inserted it right after

$submittedField = $field->getSubmittedFormField();
$submittedField->ParentID = $submittedForm->ID;
$submittedField->Name = $field->Name;
$submittedField->Title = $field->Title;

Any ideas?