{"id":19719435,"url":"https://github.com/leapt/slug-type-bundle","last_synced_at":"2025-04-29T21:30:26.737Z","repository":{"id":66748508,"uuid":"603043887","full_name":"leapt/slug-type-bundle","owner":"leapt","description":null,"archived":false,"fork":false,"pushed_at":"2024-05-22T21:22:52.000Z","size":285,"stargazers_count":8,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"1.x","last_synced_at":"2024-05-22T21:45:43.166Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leapt.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG-1.x.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-17T13:59:29.000Z","updated_at":"2024-05-22T21:22:52.000Z","dependencies_parsed_at":"2024-05-22T21:44:39.808Z","dependency_job_id":"d1a97bc0-44e0-4e54-833c-dc1275b18dbb","html_url":"https://github.com/leapt/slug-type-bundle","commit_stats":{"total_commits":23,"total_committers":1,"mean_commits":23.0,"dds":0.0,"last_synced_commit":"17d8ce2977d21d4568e44a55a8422d2b0e57aec0"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leapt%2Fslug-type-bundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leapt%2Fslug-type-bundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leapt%2Fslug-type-bundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leapt%2Fslug-type-bundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leapt","download_url":"https://codeload.github.com/leapt/slug-type-bundle/tar.gz/refs/heads/1.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251585719,"owners_count":21613269,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T23:08:17.434Z","updated_at":"2025-04-29T21:30:26.449Z","avatar_url":"https://github.com/leapt.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Leapt SlugType bundle\n\n[![Package version](https://img.shields.io/packagist/v/leapt/slug-type-bundle.svg?style=flat-square)](https://packagist.org/packages/leapt/slug-type-bundle)\n[![Build Status](https://img.shields.io/github/actions/workflow/status/leapt/slug-type-bundle/continuous-integration.yaml?branch=1.x\u0026style=flat-square)](https://github.com/leapt/slug-type-bundle/actions?query=workflow%3A%22Continuous+Integration%22)\n![PHP Version](https://img.shields.io/packagist/php-v/leapt/slug-type-bundle.svg?branch=1.x\u0026style=flat-square)\n[![License](https://img.shields.io/badge/license-MIT-red.svg?style=flat-square)](LICENSE)\n[![Code coverage](https://img.shields.io/codecov/c/github/leapt/slug-type-bundle?style=flat-square)](https://codecov.io/gh/leapt/slug-type-bundle/branch/1.x)\n\nLeapt SlugType bundle makes a form field dynamically generate the slug based on the content of another text field.\n\n![Demo](demo.gif)\n\n## Requirements\n\n- PHP ^8.2\n- Symfony ^6.4 or ^7.0\n- Webpack Encore \u0026 Stimulus bridge already present in your project\n\n## Installation\n\n```bash\ncomposer require leapt/slug-type-bundle\n\n# Don't forget to install the JavaScript dependencies as well and compile\nnpm install --force\nnpm run watch\n\n# or use yarn\nyarn install --force\nyarn watch\n```\n\nThen, in your Twig configuration, add the form theme you want to apply:\n\n```yaml\n# config/packages/twig.yaml\ntwig:\n    form_themes:\n        - '@LeaptSlugType/bootstrap5_layout.html.twig'\n```\n\nThere are currently 3 form themes available:\n\n- `@LeaptSlugType/basic_layout.html.twig`\n- `@LeaptSlugType/bootstrap4_layout.html.twig`\n- `@LeaptSlugType/bootstrap5_layout.html.twig`\n\n## Usage\n\nIn your form type, use the `SlugType` on the field that will handle the slug, and give it a `target` option that will be\nused to generate the slug:\n\n```php\n\u003c?php\n\nnamespace App\\Form\\Type;\n\nuse Leapt\\SlugTypeBundle\\Form\\SlugType;\nuse Symfony\\Component\\Form\\AbstractType;\nuse Symfony\\Component\\Form\\Extension\\Core\\Type\\TextType;\nuse Symfony\\Component\\Form\\FormBuilderInterface;\n\nfinal class CenterType extends AbstractType\n{\n    public function buildForm(FormBuilderInterface $builder, array $options): void\n    {\n        $builder\n            -\u003eadd('name', TextType::class)\n            -\u003eadd('slug', SlugType::class, [\n                'target' =\u003e 'name',\n            ])\n        ;\n    }\n}\n```\n\nBy default, for Bootstrap 4 \u0026 5 themes, a `btn-secondary` class is applied to the lock button. You can change it\nby using the `button_class` option for any form theme:\n\n```php\n$builder-\u003eadd('slug', SlugType::class, [\n    'target' =\u003e 'name',\n    'button_class' =\u003e 'btn-warning',\n]);\n```\n\nYou can also customize the locked \u0026 unlocked icons. By default, it uses emojis, but if you use e.g. FontAwesome you can\noverride it:\n\n```php\n$builder-\u003eadd('slug', SlugType::class, [\n    'target' =\u003e 'name',\n    'locked_icon' =\u003e '\u003ci class=\"fas fa-fw fa-lock\"\u003e\u003c/i\u003e',\n    'unlocked_icon' =\u003e '\u003ci class=\"fas fa-fw fa-lock-open\"\u003e\u003c/i\u003e',\n]);\n```\n\n## Customizing the design\n\nThe bundle provides a default stylesheet in order to add a gray background to the readonly input.\nYou can disable it to add your own design if you wish.\n\nIn `assets/controllers.json`, disable the default stylesheet by switching the `@leapt/slug-type-bundle/dist/style.css`\nautoimport to `false`:\n\n```json\n{\n    \"controllers\": {\n        \"@leapt/slug-type-bundle\": {\n            \"slug\": {\n                \"enabled\": true,\n                \"fetch\": \"eager\",\n                \"autoimport\": {\n                    \"@leapt/slug-type-bundle/dist/style.css\": false\n                }\n            }\n        }\n    },\n    \"entrypoints\": []\n}\n```\n\nNote: you should put the value to false and not remove the line so that Symfony Flex won't try to add the line again\nin the future.\n\nOnce done, the default stylesheet won’t be used anymore, and you can implement your own CSS on top of the input.\n\n## Contributing\n\nFeel free to contribute, like sending [pull requests](https://github.com/leapt/slug-type-bundle/pulls) to add\nfeatures/tests or [creating issues](https://github.com/leapt/slug-type-bundle/issues) :)\n\nNote there are a few helpers to maintain code quality, that you can run using these commands:\n\n```bash\ncomposer cs:dry # Code style check\ncomposer cs:fix # Fix code style\ncomposer phpstan # Static analysis\ncomposer phpunit # Run tests\n\n# Or run all cs:dry, phpstan \u0026 phpunit scripts using the following:\ncomposer ci\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleapt%2Fslug-type-bundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleapt%2Fslug-type-bundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleapt%2Fslug-type-bundle/lists"}