Mask is getting applied twice sometimes?

Hello guys, I currently have a strange problem. It looks like sometimes (maybe at the first loading) the mask gets applied twice and this is impacting the user experience a lot unfortunately. My InputField is a custom TextInput
3 Replies
BuggerSee
BuggerSeeOP15mo ago
As you can see sometimes the mask is applied twice and changing this number: 9373-4150-3754-7693 to this number: 9373--415-0-37-54-7
DarkKnight
DarkKnight15mo ago
Can you share some code?
BuggerSee
BuggerSeeOP15mo ago
Sure, I'm right now not sure if it is a mask problem. When i add the getOrcidAttribute function, the mistake is gone.
class Member extends Model
{
protected $table = 'members';

protected $fillable = [
'first_name',
'middle_name',
'last_name',
'country',
'institution',
'gender',
'orcid',
'profile_picture_url',

'organizing_member_role_id',
'sc_member_type_id',
'sc_member_since',
'sc_member_until',

'memberable_id',
'memberable_type',
'memberable_email',
];

public function setOrcidAttribute($value): void
{
// Remove any hyphens that might already be in the string
$cleanedValue = str_replace('-', '', $value);

// Insert hyphens at the correct positions
$formattedValue = substr($cleanedValue, 0, 4) . '-'
. substr($cleanedValue, 4, 4) . '-'
. substr($cleanedValue, 8, 4) . '-'
. substr($cleanedValue, 12, 4);

$this->attributes['orcid'] = $formattedValue;
}

// public function getOrcidAttribute($value): string
// {
// return str_replace('-', '', $value);
// }
class Member extends Model
{
protected $table = 'members';

protected $fillable = [
'first_name',
'middle_name',
'last_name',
'country',
'institution',
'gender',
'orcid',
'profile_picture_url',

'organizing_member_role_id',
'sc_member_type_id',
'sc_member_since',
'sc_member_until',

'memberable_id',
'memberable_type',
'memberable_email',
];

public function setOrcidAttribute($value): void
{
// Remove any hyphens that might already be in the string
$cleanedValue = str_replace('-', '', $value);

// Insert hyphens at the correct positions
$formattedValue = substr($cleanedValue, 0, 4) . '-'
. substr($cleanedValue, 4, 4) . '-'
. substr($cleanedValue, 8, 4) . '-'
. substr($cleanedValue, 12, 4);

$this->attributes['orcid'] = $formattedValue;
}

// public function getOrcidAttribute($value): string
// {
// return str_replace('-', '', $value);
// }
Numbers are saved like this in the database: 0008-9255-8427-9455 The error is also not in the custom Input Field because i render a TextInput under it to debug and it shows the same problem
Want results from more Discord servers?
Add your server