When leveraging another plugin programmatically, you will typically want to use the service layer. In your case, the
SproutForms_EntriesService.php is where the
saveEntry action gets processed. The
saveEntry service method expects a
Here is a longer example:
// Create a new instance of a SproutForms_EntryModel
$entry = new SproutForms_EntryModel();
// Set some SproutForms_EntryModel attributes
$entry->formId = 4051;
$entry->ipAddress = '127.0.0.1';
$entry->userAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.116 Safari/537.36';
// Set the custom fields
'fullName' => 'Test Name',
'message' => 'Test message'
// Save the entry
Sprout Forms should dynamically set the title value for you, based on the value you have in the
Advanced->Title Format setting.
In the case it doesn't seem to work, a quick way to see if there are any errors is to kill your script after you tried to save the entry and view the full list of errors (or use a more advanced PHP debugging workflow with a tool like XDebug):
See the answer from Brandon Kelly on this post for more information on how to set custom fields on an Element.