Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add HasCharacterLimit Trait and Update README #16

Closed
wants to merge 3 commits into from
Closed

Add HasCharacterLimit Trait and Update README #16

wants to merge 3 commits into from

Conversation

edeoliv
Copy link

@edeoliv edeoliv commented Aug 7, 2024

Summary

This pull request introduces the HasCharacterLimit trait and updates the README documentation to reflect this new feature.

Changes

  • Added HasCharacterLimit trait to the LaraZeus\Quantity\Traits component.
  • Updated the README with instructions on how to use the characterLimit method.

Usage

To set a character limit on the amount_number field, use the characterLimit method as shown below:

\LaraZeus\Quantity\Components\Quantity::make('amount_number')
    ->heading('Select Quantity')
    ->default(3)
    ->maxValue(10)
    ->minValue(2)
    ->characterLimit(2) // Add this line to set the character limit
    ->stacked();

@edeoliv edeoliv closed this Aug 7, 2024
@edeoliv
Copy link
Author

edeoliv commented Aug 7, 2024

I forgot to modify the view, as soon as I modify it to show the characters I reopen the PR

@atmonshi
Copy link
Member

atmonshi commented Aug 7, 2024

thank you so much for your contribution.

but I am just confused, what the different between the new method: characterLimit and the existing one: maxValue and maxValue ?

the use for quantity is for numbers only. and you can set the max and min value.

@atmonshi
Copy link
Member

atmonshi commented Aug 7, 2024

and the same for: CanBeShownInsideControl vs stacked! :)

@edeoliv
Copy link
Author

edeoliv commented Aug 7, 2024

Basically what it does is to display the number of allowed characters and as the field is filled in it updates the number of allowed characters. So it is different from what you already have in the plugin.

imagen

@atmonshi
Copy link
Member

atmonshi commented Aug 8, 2024

so it show the allowed length of the input, you could use strlen or something similar for that and display it as a hint text or help text, so no need for a new method that can get others confusing too.

in you example form the screenshot the strlen will be 2 if you set your max value to 99.

@edeoliv
Copy link
Author

edeoliv commented Aug 8, 2024

Well for me it works with the addition of the new method and I take advantage of it in a general way in the whole project without strlen and similar, but well respect your decision in the end is your plugin your rules.
Sorry for the inconvenience

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants