I think it should be:

  public static function generateSampleValue(FieldDefinitionInterface $field_definition) {
    $values['value'] = (string) rand(pow(10, 8), pow(10, 9) - 1);
    return $values;
  }

Comments

super_romeo created an issue. See original summary.

super_romeo’s picture

Issue summary: View changes

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

NitinLama’s picture

Assigned: Unassigned » NitinLama
Status: Active » Needs work
NitinLama’s picture

Assigned: NitinLama » Unassigned
Status: Needs work » Needs review
StatusFileSize
new660 bytes
super_romeo’s picture

Patch works. Thanks! :)

tanubansal’s picture

Tested #6
RTBC + 1

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

ranjith_kumar_k_u’s picture

The #6 patch works fine on 9.2.x dev.RTBC

ranjith_kumar_k_u’s picture

StatusFileSize
new656 bytes

Re-rolled

Status: Needs review » Needs work

The last submitted patch, 11: 3076979-11.patch, failed testing. View results

ranjith_kumar_k_u’s picture

StatusFileSize
new655 bytes

please review

kapilv’s picture

Status: Needs work » Needs review
StatusFileSize
new456 bytes
super_romeo’s picture

Status: Needs review » Reviewed & tested by the community

Works for me.

xjm’s picture

Status: Reviewed & tested by the community » Needs review

According to the config schema for telephone:

# Schema for the configuration files of the Telephone module.

field.formatter.settings.telephone_link:
  type: mapping
  label: 'Telephone link format settings'
  mapping:
    title:
      type: label
      label: 'Title to replace basic numeric telephone number display'

field.widget.settings.telephone_default:
  type: mapping
  label: 'Telephone default format settings'
  mapping:
    placeholder:
      type: label
      label: 'Placeholder'

field.value.telephone:
  type: mapping
  label: 'Default value'
  mapping:
    value:
      type: string
      label: 'Value'

The value is already defined to be a string, so theoretically this generated sample value should be converted automatically to a string on save.

Do you have an example of where this is not the case, or example code for which it caused issues?

Also, what does the method documentation for the parent method currently say about the return value?

With these questions, I'm trying to sort out if there are other places that may need a bugfix or if there is missing test coverage.

vikashsoni’s picture

Applied patch #6 working successfully

Madhu kumar’s picture

StatusFileSize
new23.84 KB

Applied patch #13 working as expected , and value is converted to string format.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

laisbonafe’s picture

Assigned: Unassigned » laisbonafe
laisbonafe’s picture

Assigned: laisbonafe » Unassigned
Status: Needs review » Reviewed & tested by the community

Patch #13 working well, no problens detected in tests.
if still couse a issue , tell me more and we will review again

bnjmnm’s picture

Status: Reviewed & tested by the community » Needs review

This issue was set to RTBC in #15 and was switched back to "Needs review" by a committer in #16, where several questions were asked. This shouldn't be set back to RTBC until those questions are answered (or there's evidence they don't need to be).

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Status: Needs review » Postponed (maintainer needs more info)

Moving to PNMI based on the questions in #16

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)
Issue tags: +Bug Smash Initiative

Closing as outdated as this moved to PNMI 4 months ago without a followup.

If still an issue please reopen addressing #16