Skip to content

Commit 4680720

Browse files
authored
Merge pull request #74 from tetranz/readme-fix
Fix headings in README
2 parents 0caa0aa + 0878c35 commit 4680720

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

Diff for: README.md

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
select2entity-bundle
22
====================
33

4-
##Introduction##
4+
## Introduction
55

66
This is a Symfony2 bundle which enables the popular [Select2](https://select2.github.io) component to be used as a drop-in replacement for a standard entity field on a Symfony form.
77

@@ -13,7 +13,7 @@ The project was inspired by [lifo/typeahead-bundle](https://github.com/lifo101/t
1313

1414
Thanks to @ismailbaskin we now have Select2 version 4 compatibility.
1515

16-
##Screenshots##
16+
## Screenshots
1717

1818
This is a form with a single selection field list expanded.
1919

@@ -23,7 +23,7 @@ This is a form with a multiple selection field list expanded.
2323

2424
![Multiple select example](Resources/doc/img/multi.png)
2525

26-
##Installation##
26+
## Installation
2727

2828
Select2 must be installed and working first. I hope to setup a demo site but my setup is basically [BraincraftedBootstrapBundle](http://bootstrap.braincrafted.com) with Select2 installed for Bootstrap 3. Once the Braincrafted bundle is working, the only files I've needed to install are:
2929

@@ -71,7 +71,7 @@ twig:
7171
<script src="{{ asset('bundles/tetranzselect2entity/js/select2entity.js') }}"></script>
7272
```
7373

74-
##How to use##
74+
## How to use
7575

7676
The following is for Symfony 3. The latest version works on both Symfony 2 and Symfony 2 but see https://github.com/tetranz/select2entity-bundle/tree/v2.1 for Symfony 2 configuration and use.
7777

@@ -103,7 +103,7 @@ Put this at the top of the file with the form type class:
103103
use Tetranz\Select2EntityBundle\Form\Type\Select2EntityType;
104104
```
105105

106-
##Options##
106+
## Options
107107
Defaults will be used for some if not set.
108108
* `class` is your entity class. Required
109109
* `primary_key` is the name of the property used to uniquely identify entities. Defaults to 'id'
@@ -146,7 +146,7 @@ tetranz_select2_entity:
146146
scroll: true
147147
```
148148
149-
##AJAX Response##
149+
## AJAX Response
150150
The controller should return a `JSON` array in the following format. The properties must be `id` and `text`.
151151

152152
```javascript
@@ -155,7 +155,7 @@ The controller should return a `JSON` array in the following format. The propert
155155
{ id: 2, text: 'Displayed Text 2' }
156156
]
157157
```
158-
##Infinite Scrolling##
158+
## Infinite Scrolling
159159
If your results are being paged via the Select2 "infinite scrolling" feature then you can either continue to return
160160
the same array as shown above _(for Backwards Compatibility this bundle will automatically try to determine if more
161161
results are needed)_, or you can return an object shown below to have finer control over the paged results.
@@ -174,7 +174,7 @@ The `more` field should be true if there are more results to be loaded.
174174
Your controller action that fetches the results will receive a parameter `page` indicating what page of results should
175175
be loaded. If you set scroll to true then you must handle the page parameter in the query. Weird things will happen if you don't.
176176

177-
##Custom option text##
177+
## Custom option text
178178
If you need more flexibility in what you display as the text for each option, such as displaying the values of several fields from your entity or showing an image inside, you may define your own custom transformer.
179179
Your transformer must implement DataTransformerInterface. The easiest way is probably to extend EntityToPropertyTransformer or EntitiesToPropertyTransformer and redefine the transform() method. This way you can return as `text` anything you want, not just one entity property.
180180

@@ -204,7 +204,7 @@ Your custom transformer and respectively your Ajax controller should return an a
204204
```
205205
If you are using the allow_add option and your entity requires other fields besides the text_property field to be valid, you will either need to extend the EntitiesToPropertyTransformer to add the missing field, create a doctrine prePersist listener, or add the missing data in the form view after submit before saving.
206206

207-
###Add New Tags###
207+
### Add New Tags
208208

209209
If you want to be able to create new entities through Select2 tags, you can enable it using the `allow_add` set of options.
210210

@@ -242,7 +242,7 @@ $builder
242242
```
243243

244244

245-
###Templating###
245+
### Templating
246246

247247
If you need [Templating](https://select2.github.io/examples.html#templating) in Select2, you could consider the following example that shows the country flag next to each option.
248248

@@ -301,7 +301,7 @@ You also will need to override the following block in your template:
301301
```
302302
This block adds all additional data needed to the JavaScript function `select2entityAjax`, like data attribute. In this case we are passing `data-img`.
303303

304-
##Embed Collection Forms##
304+
## Embed Collection Forms
305305
If you use [Embedded Collection Forms](http://symfony.com/doc/current/cookbook/form/form_collections.html) and [data-prototype](http://symfony.com/doc/current/cookbook/form/form_collections.html#allowing-new-tags-with-the-prototype) to add new elements in your form, you will need the following JavaScript that will listen for adding an element `.select2entity`:
306306
```javascript
307307
$('body').on('click', '[data-prototype]', function(e) {

0 commit comments

Comments
 (0)