Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I have a multivalue text field and have filled it with value. if i try to get this value the return value is empty.
The genereated getter / setter methods:
/**
* Sets field_validation_tokens
*
* @param $value
*
* @return $this
*/
public function setValidationTokens($value, $format = NULL) {
$this->setText('field_validation_tokens', $value, $format);
return $this;
}
/**
* Retrieves field_validation_tokens
*
* @return mixed
*/
public function getValidationTokens($format = WdEntityWrapper::FORMAT_DEFAULT, $markup_format = NULL) {
return $this->getText('field_validation_tokens', $format, $markup_format);
}
Comment | File | Size | Author |
---|---|---|---|
#3 | wrappers_delight-multivalue-text-fields-2785339-3.patch | 8.13 KB | zengenuity |
|
Comments
Comment #2
fox_01 CreditAttribution: fox_01 commentedif i switch the field to single value then it returns the correct value
Comment #3
zengenuity CreditAttribution: zengenuity at DrupalTutor / Zengenuity commentedPlease test this patch.
You will need to regenerate the getters and setters in your bundle classes to test. Just delete those functions and run the drush command again.
Please let me know if this works for you.
Comment #4
zengenuity CreditAttribution: zengenuity at DrupalTutor / Zengenuity commentedComment #5
fox_01 CreditAttribution: fox_01 commented#3 Works.
Thanks for that quick response
Comment #7
zengenuity CreditAttribution: zengenuity at DrupalTutor / Zengenuity commented#3 committed.
Comment #8
fox_01 CreditAttribution: fox_01 commentedI have found a new issue from the patch.
If i have a single value text field and do a drush wrap on a new entity i get generated the function "$this->setTextMultiple" instead of "$this->setText" in the getter / setter method. This leads to an error in the foreach loop. If i manually modify the line $this->setTextMultiple to $this->setTextMultiple then it works.
Comment #9
zengenuity CreditAttribution: zengenuity at DrupalTutor / Zengenuity commentedI tested the single-value text field scenario as when I was making the patch, and it was working for me. Can you give me more details about the field you are having trouble with? Text or Text Long? Filtered or Plain Text? Anything else unusual with it?
Comment #10
zengenuity CreditAttribution: zengenuity at DrupalTutor / Zengenuity commentedOh wait, are you saying that you're setting a single value on a multiple value field? In that case, you need to be passing an array. Wrap the value in an array when it's a multi-value field.
Comment #11
fox_01 CreditAttribution: fox_01 commentedIts a normal plain text field single value named street.
What i was trying to do is this
I am getting the warning
I have found that the getter has the wrong function
If i mody this line to the following its working
Comment #12
zengenuity CreditAttribution: zengenuity at DrupalTutor / Zengenuity commentedThe patch is the problem. It doesn't have the new files I added.
I've committed the changes. Can you try it with the dev version? Let me know if it works correctly then.
Comment #13
fox_01 CreditAttribution: fox_01 commentedworks now as you described