add a required field to custom fields type

ref Chill-project/Chill-CustomFields#17
This commit is contained in:
2015-12-10 17:16:59 +01:00
parent b88bb50b56
commit 3230659a4b
11 changed files with 136 additions and 2 deletions

View File

@@ -22,6 +22,8 @@ Chill\CustomFieldsBundle\Entity\CustomField:
type: float
options:
type: json_array
required:
type: boolean
lifecycleCallbacks: { }
manyToOne:
customFieldGroup:

View File

@@ -0,0 +1,35 @@
<?php
namespace Application\Migrations;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
class Version20151210155904 extends AbstractMigration
{
/**
* @param Schema $schema
*/
public function up(Schema $schema)
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('ALTER TABLE customfield ADD required BOOLEAN DEFAULT FALSE');
}
/**
* @param Schema $schema
*/
public function down(Schema $schema)
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('ALTER TABLE CustomField DROP required');
}
}

View File

@@ -39,6 +39,9 @@ General informations: Informations générales
Options: Options
Custom fields group: Groupe de champ personnalisé
Ordering: Ordre d'apparition
Required field: Champs requis
An answer is required: Une réponse est requise
Any answer is required: Aucune réponse n'est requise
Back to the group: Retour au groupe de champs personnalisé
Slug: Identifiant textuel
The custom field has been created: Le champ personnalisé est créé

View File

@@ -29,6 +29,7 @@
{{ form_row(edit_form.customFieldsGroup) }}
{% endif %}
{{ form_row(edit_form.ordering) }}
{{ form_row(edit_form.required) }}
{% if edit_form.options is not empty %}
<h2>{{ 'Options'|trans }}</h2>
{% for option in edit_form.options %}

View File

@@ -30,6 +30,7 @@
{{ form_row(form.customFieldsGroup) }}
{% endif %}
{{ form_row(form.ordering) }}
{{ form_row(form.required) }}
{% if form.options is not empty %}
<h2>{{ 'Options'|trans }}</h2>
{% for option in form.options %}