We are building a custom frontend form allowing users to create their own entries. How can we set the sprout fields programmatically in the backend? This is what we have tried so far with the phone field:

$request = Craft::$app->request;

$phone = $request->getBodyParam('phone');

$artist = new Entry();

/** Set other fields... */

$artist->setFieldValue('phone', $phone);

$success = Craft::$app->elements->saveElement($artist);

if (!$success) {
    return $this->sendErrors($artist, $user);

return null;

We can query artist.phone in a template, and sure enough, it returns the value. However, in the craft admin panel, the field is blank. Is there a correct way of setting a sprout field?

We need to set the phone and address fields. Thanks for your support!

  • Are you trying to set a unique Sprout field, or have the field auto populate? – JJefferyDev Jun 2 at 23:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.