mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +00:00
Adding Title for Custom Field
This commit is contained in:
parent
a6ae6ca5a9
commit
1747ba5f0d
70
CustomFields/CustomFieldTitle.php
Normal file
70
CustomFields/CustomFieldTitle.php
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Chill is a software for social workers
|
||||||
|
*
|
||||||
|
* Copyright (C) 2014, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Chill\CustomFieldsBundle\CustomFields;
|
||||||
|
|
||||||
|
use Chill\CustomFieldsBundle\CustomFields\CustomFieldInterface;
|
||||||
|
use Chill\CustomFieldsBundle\Entity\CustomField;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
use Symfony\Component\HttpFoundation\RequestStack;
|
||||||
|
|
||||||
|
class CustomFieldTitle implements CustomFieldInterface
|
||||||
|
{
|
||||||
|
private $requestStack;
|
||||||
|
|
||||||
|
public function __construct(RequestStack $requestStack)
|
||||||
|
{
|
||||||
|
$this->requestStack = $requestStack;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function buildForm(FormBuilderInterface $builder, CustomField $customField)
|
||||||
|
{
|
||||||
|
$builder->add($customField->getSlug(), 'custom_field_title', array(
|
||||||
|
'label' => $customField->getLabel(
|
||||||
|
$this->requestStack->getCurrentRequest()->getLocale())
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function render($value, CustomField $customField)
|
||||||
|
{
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function serialize($value, CustomField $customField)
|
||||||
|
{
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function deserialize($serialized, CustomField $customField)
|
||||||
|
{
|
||||||
|
return $serialized;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName()
|
||||||
|
{
|
||||||
|
return 'title';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function buildOptionsForm(FormBuilderInterface $builder)
|
||||||
|
{
|
||||||
|
return $builder;
|
||||||
|
}
|
||||||
|
}
|
38
Form/Type/CustomFieldsTitleType.php
Normal file
38
Form/Type/CustomFieldsTitleType.php
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Chill is a software for social workers
|
||||||
|
*
|
||||||
|
* Copyright (C) 2014, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
namespace Chill\CustomFieldsBundle\Form\Type;
|
||||||
|
|
||||||
|
use Symfony\Component\Form\AbstractType;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
|
class CustomFieldsTitleType extends AbstractType
|
||||||
|
{
|
||||||
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName()
|
||||||
|
{
|
||||||
|
return 'custom_field_title';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -6,20 +6,20 @@ services:
|
|||||||
class: Chill\CustomFieldsBundle\Routing\RoutesLoader
|
class: Chill\CustomFieldsBundle\Routing\RoutesLoader
|
||||||
tags:
|
tags:
|
||||||
- { name: routing.loader }
|
- { name: routing.loader }
|
||||||
|
|
||||||
chill.custom_field.provider:
|
chill.custom_field.provider:
|
||||||
class: Chill\CustomFieldsBundle\Service\CustomFieldProvider
|
class: Chill\CustomFieldsBundle\Service\CustomFieldProvider
|
||||||
call:
|
call:
|
||||||
- [setContainer, ["@service_container"]]
|
- [setContainer, ["@service_container"]]
|
||||||
|
|
||||||
chill.custom_field.custom_field_choice_type:
|
chill.custom_field.custom_field_choice_type:
|
||||||
class: Chill\CustomFieldsBundle\Form\CustomFieldType
|
class: Chill\CustomFieldsBundle\Form\CustomFieldType
|
||||||
arguments:
|
arguments:
|
||||||
- "@chill.custom_field.provider"
|
- "@chill.custom_field.provider"
|
||||||
|
|
||||||
tags:
|
tags:
|
||||||
- { name: 'form.type', alias: 'custom_field_choice' }
|
- { name: 'form.type', alias: 'custom_field_choice' }
|
||||||
|
|
||||||
chill.custom_field.custom_fields_group_type:
|
chill.custom_field.custom_fields_group_type:
|
||||||
class: Chill\CustomFieldsBundle\Form\CustomFieldsGroupType
|
class: Chill\CustomFieldsBundle\Form\CustomFieldsGroupType
|
||||||
arguments:
|
arguments:
|
||||||
@ -27,7 +27,7 @@ services:
|
|||||||
- "@translator"
|
- "@translator"
|
||||||
tags:
|
tags:
|
||||||
- { name: 'form.type', alias: 'custom_fields_group' }
|
- { name: 'form.type', alias: 'custom_fields_group' }
|
||||||
|
|
||||||
chill.custom_field.custom_field_type:
|
chill.custom_field.custom_field_type:
|
||||||
class: Chill\CustomFieldsBundle\Form\Type\CustomFieldType
|
class: Chill\CustomFieldsBundle\Form\Type\CustomFieldType
|
||||||
arguments:
|
arguments:
|
||||||
@ -35,15 +35,27 @@ services:
|
|||||||
- "@chill.custom_field.provider"
|
- "@chill.custom_field.provider"
|
||||||
tags:
|
tags:
|
||||||
- { name: 'form.type', alias: 'custom_field' }
|
- { name: 'form.type', alias: 'custom_field' }
|
||||||
|
|
||||||
chill.custom_field.text:
|
chill.custom_field.text:
|
||||||
class: Chill\CustomFieldsBundle\CustomFields\CustomFieldText
|
class: Chill\CustomFieldsBundle\CustomFields\CustomFieldText
|
||||||
tags:
|
tags:
|
||||||
- { name: 'chill.custom_field', type: 'text' }
|
- { name: 'chill.custom_field', type: 'text' }
|
||||||
|
|
||||||
chill.custom_field.address:
|
chill.custom_field.address:
|
||||||
class: Chill\CustomFieldsBundle\CustomFields\CustomFieldAddress
|
class: Chill\CustomFieldsBundle\CustomFields\CustomFieldAddress
|
||||||
arguments:
|
arguments:
|
||||||
- "@doctrine.orm.entity_manager"
|
- "@doctrine.orm.entity_manager"
|
||||||
tags:
|
tags:
|
||||||
- { name: 'chill.custom_field', type: 'address' }
|
- { name: 'chill.custom_field', type: 'address' }
|
||||||
|
|
||||||
|
chill.custom_field.custom_fields_title_type:
|
||||||
|
class: Chill\CustomFieldsBundle\Form\Type\CustomFieldsTitleType
|
||||||
|
tags:
|
||||||
|
- { name: 'form.type', alias: 'custom_field_title' }
|
||||||
|
|
||||||
|
chill.custom_field.title:
|
||||||
|
class: Chill\CustomFieldsBundle\CustomFields\CustomFieldTitle
|
||||||
|
arguments:
|
||||||
|
- "@request_stack"
|
||||||
|
tags:
|
||||||
|
- { name: 'chill.custom_field', type: 'title' }
|
||||||
|
3
Resources/views/Form/form_div_layout.html.twig
Normal file
3
Resources/views/Form/form_div_layout.html.twig
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{% block custom_field_title_widget %}
|
||||||
|
dump(attr)
|
||||||
|
{% endblock custom_field_title_widget %}
|
Loading…
x
Reference in New Issue
Block a user