nova-text-copy-field icon indicating copy to clipboard operation
nova-text-copy-field copied to clipboard

Set text label/value next to button

Open RicLeP opened this issue 6 years ago • 1 comments

It would be useful to be able to override the text shown by the button. For instance I want to use a generated copyValue that has no corresponding row in the database in meaning only the button shows.

TextCopy::make('Social link')
->copyValue(function () {
	return $this->url;
}),

Other times I might have a long item to copy like a URL and rather and truncate it, it would ne good to supply different word like copy link.

At the moment I work around it by supplying a second argument to the make method which uses an accessor on the model that returns a string.

// resource
TextCopy::make('Social link', 'social_link_copy_label')
->copyValue(function () {
	return $this->url;
}),

// model
public function getSocialLinkCopyLabelAttribute()
{
	return 'Copy url';
}

RicLeP avatar Apr 11 '19 16:04 RicLeP

To clarify, you are looking for the button text to be flexible. So rather than the "copy icon", you could set your own value to something like "Copy Link"

Screen Shot 2019-04-15 at 4 12 06 PM

sixlive avatar Apr 15 '19 20:04 sixlive