From b9cd62a3efb12b23a2b8595bb23b31ebcc06a59f Mon Sep 17 00:00:00 2001 From: Vincent BEAUVIVRE Date: Thu, 9 Nov 2017 14:08:44 +0100 Subject: [PATCH] Add process to extends entities --- README.md | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/README.md b/README.md index ffb9ee0..8cbe481 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,84 @@ overridden as with any other bundle, by creating translation files in the To get started, check the bundle's main language file in: [Resources/translations/messages.en.yml](Resources/translations/messages.en.yml) +## Extends our entities + +To add fields to an entity, you must create your own entity that extends ours. +Here is an example to add «closing days» to translated values of a location : +``` +closingDays = $closingDays; + + return $this; + } + + public function getClosingDays() + { + return $this->closingDays; + } +} + +``` + +Then add your own fields to edit form, extending our form type : +``` +add('closingDays', TextareaType::class, [ + 'label' => 'webburza_location.form.location.closingDays' + ]); + } +} +``` +By the way, you can change also widget here, instead of «TextareaType». You can use CkeditorType for example. + +Finaly, you must configure symfony to use this. Add this to ``app/config/config.yml`` (or another config file) : +``` +parameters: + webburza_location.model.location_translation.class: AppBundle\Entity\MyLocationTranslation + webburza_location.form.type.location_translation.class: AppBundle\Type\MyLocationTranslationType + +``` + +And do not forget to add translation string for ```webburza_location.form.location.closingDays``` + +You’re done ! + + ## License This bundle is available under the [MIT license](LICENSE).