Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Beta Datetimepicker Bundle Laravel Package

digitalframe/beta-datetimepicker-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation:

    composer require digitalframe/datetimepicker-bundle:dev-master
    

    Update AppKernel.php to include the bundle:

    new Digitalframe\DatetimepickerBundle\DigitalframeDatetimepickerBundle(),
    
  2. Configure: Add minimal config in config.yml:

    digitalframe_datetimepicker: ~
    
  3. Assets: Run:

    php app/console assets:install web/
    

First Use Case

Add the field type to a form:

// src/AppBundle/Form/YourFormType.php
public function buildForm(FormBuilderInterface $builder, array $options) {
    $builder->add('eventDate', 'df_datetime');
}

Include the bundle’s JS/CSS in your template:

{{ form_stylesheets(form) }}
{{ form_javascripts(form) }}

Implementation Patterns

Common Workflows

  1. Basic Integration: Use 'df_datetime' as a field type in forms. Defaults to English locale and MM/DD/YYYY HH:mm format.

  2. Localized Picker: Override defaults per field:

    $builder->add('birthday', 'df_datetime', [
        'locale' => 'fr',
        'format' => 'DD/MM/YYYY'
    ]);
    
  3. Dynamic Configuration: Pass options via form options or entity properties (if using DataTransformer or custom logic).

  4. Reusing in Templates: Render the field with Twig:

    {{ form_row(form.eventDate) }}
    

Integration Tips

  • Symfony 3/4+: Test compatibility with symfony/form (this bundle targets Symfony 2).
  • Asset Management: Use webpack or encore for modern builds if assets are bundled.
  • Custom Templates: Override DigitalframeDatetimepickerBundle::datetime_widget.html.twig for UI tweaks.

Gotchas and Tips

Pitfalls

  1. Asset Conflicts:

    • Ensure no duplicate datetimepicker.js or bootstrap-datetimepicker.css exists in your project.
    • Clear cache after assets:install:
      php app/console cache:clear
      
  2. Locale Mismatch:

    • The bundle relies on moment.js locales. Ensure the locale (e.g., 'es') matches a loaded moment.js locale.
  3. Symfony 2 Legacy:

    • Uses FormBuilder (not FormBuilderInterface), which may cause issues in newer Symfony versions.
    • Test thoroughly with Symfony 2.8+.
  4. Missing Dependencies:

    • Requires bootstrap and jquery (check form_stylesheets/form_javascripts output).

Debugging

  • Console Errors: Check browser console for moment.js or datetimepicker initialization errors (e.g., missing locales).
  • Form Rendering: If the picker doesn’t appear, verify:
    • JS/CSS are loaded (inspect <head>).
    • Field type is correctly registered ('df_datetime').

Extension Points

  1. Custom Options: Extend the bundle’s DatetimeType to add new options:

    // src/AppBundle/Form/Extension/DatetimeExtension.php
    use Symfony\Component\Form\AbstractTypeExtension;
    class DatetimeExtension extends AbstractTypeExtension {
        public function getExtendedType() {
            return 'df_datetime';
        }
        public function getDefaultOptions() {
            return ['new_option' => false];
        }
    }
    
  2. Template Overrides: Copy vendor/digitalframe/datetimepicker-bundle/Resources/views/Form/ to app/Resources/DigitalframeDatetimepickerBundle/views/Form/ for custom templates.

  3. Event Listeners: Attach logic to form events (e.g., PRE_SET_DATA) to dynamically set options:

    $form->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
        $event->getForm()->add('customField', 'df_datetime', ['format' => 'YYYY']);
    });
    
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
calmfox/watch-sylius
damienfern/grpc-symfony-bundle
atoolo/index-bundle
atoolo/genai-bundle
coprotoai/laravel-ticket
davidjln/llm-carbon-bundle
cryonighter/valid-request-bundle
coolms/taxonomy-bundle
coolms/field-bundle
articulate-orm/symfony
aaix/laravel-tall-architect
ephoto/akeneo-connector
emmanuelballery/eb-plantumlbundle
emielburgman/symfony-visitor-beacon
emielburgman/symfony-visit-storage
emielburgman/symfony-security-headers
emielburgman/symfony-log-viewer
emarref/xdebug-bundle
emarref/pubnub-bundle
elriseio/finance-money-bundle