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

Name attribute in datepicker component #88

Closed
oliver-yopiter opened this issue Aug 31, 2021 · 6 comments
Closed

Name attribute in datepicker component #88

oliver-yopiter opened this issue Aug 31, 2021 · 6 comments
Labels
enhancement New feature or request

Comments

@oliver-yopiter
Copy link

oliver-yopiter commented Aug 31, 2021

Hello,
we noticed that when we create a datepicker component like this:
Group::make('')->fields([$this->datePickerField('date_of_birth', __('models/persons.fields.date_of_birth'))->colspan(3)]) the created HTML output has no name attribute in the input tag like your other components.
Because we are using some third party scripts to access form inputs by their name attribute it would be awesome if you could change the template of the datepicker component so that it is also using the name we provide as first parameter when creating the component (in our case 'date_of_birth').

Additinal context
This is how our FormFields.php looks like:
public function datePickerField($name, $name_local) { return DatePicker::make($name_local, $name) ->rules(isset($this->modelClass::$rules[$name]) ? $this->modelClass::$rules[$name] : ''); }

I hope my description is clear to you. If not don't hesitate to ask further questions

@oliver-yopiter oliver-yopiter added the enhancement New feature or request label Aug 31, 2021
@tanthammar
Copy link
Owner

Thank you. I'm working on v8. I'll make sure to add this to the next release.

@tanthammar
Copy link
Owner

@oliver-yopiter I'm working on this topic but unable to find a Flatpickr config option to set the name and id attribute of the generated input.
Any suggestions?

@oliver-yopiter
Copy link
Author

@tanthammar I'm not sure if it's the right file but in my testings i found that in the file vendor/tanthammar/tall-forms-sponsors/resources/views/components/date-picker.blade.php from line 11 to 18 there is the input-tag for the datepicker. There I added the following line name="{{ $field->name }}". So that the input-tag looks like the following:
<input x-ref="dateInput" x-model="dateValue" value="{{ $value }}" type="text" name="{{ $field->name }}" placeholder="{{ filled($field->placeholder) ? $field->placeholder : trans(config('tall-forms-sponsors.date-picker-placeholder')) }}" class="flex-1 w-full outline-none border-none focus:ring-0" />
As said I'm not sure if this is the right place for the change but I got it working with this :)

@tanthammar
Copy link
Owner

Yes that will apply the name attr to the hidden input but not the flatpickr input.
Is that enough for you?

@oliver-yopiter
Copy link
Author

Yes, for our purposes this it totally fine

@tanthammar
Copy link
Owner

OK. I've added that to v8.

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

No branches or pull requests

2 participants