Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added short title to fields #6

Merged
merged 16 commits into from
Nov 17, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Changelog

## dev-develop

- FEATURE #3 Added short title to fields
- FEATURE #2 Changed title field for labels to texteditor
- ENHANCEMENT #- Updated namespaces and rename table names
- ENHANCEMENT #- Forked from `alexander-schranz/sulu-form-bundle` from commit `36a7cd11562ed0c9f64752b37707cc2771e0baca`
- ENHANCEMENT #- Forked from `alexander-schranz/sulu-form-bundle` from commit `36a7cd11562ed0c9f64752b37707cc2771e0baca`
1 change: 1 addition & 0 deletions Controller/FormController.php
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,7 @@ private function getApiEntity(Form $entity, $locale)
$fieldData['title'] = $fieldTranslation->getTitle();
$fieldData['placeholder'] = $fieldTranslation->getPlaceholder();
$fieldData['defaultValue'] = $fieldTranslation->getDefaultValue();
$fieldData['shortTitle'] = $fieldTranslation->getShortTitle();

foreach ($fieldTranslation->getOptions() as $key => $option) {
$fieldData['options[' . $key . ']'] = $option;
Expand Down
1 change: 1 addition & 0 deletions Entity/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ public function serializeForLocale($locale, Dynamic $dynamic = null)
'options' => $fieldTranslation->getOptions(),
'defaultValue' => $fieldTranslation->getDefaultValue(),
'placeholder' => $fieldTranslation->getPlaceholder(),
'shortTitle' => $fieldTranslation->getShortTitle(),
'value' => $value,
];

Expand Down
25 changes: 25 additions & 0 deletions Entity/FormFieldTranslation.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ class FormFieldTranslation
*/
private $defaultValue;

/**
* @var string
*/
private $shortTitle;

/**
* @var string
*/
Expand Down Expand Up @@ -147,6 +152,26 @@ public function setDefaultValue($defaultValue)
return $this;
}

/**
* @return string
*/
public function getShortTitle()
{
return $this->shortTitle;
}

/**
* @param string $shortTitle
*
* @return FormFieldTranslation
*/
public function setShortTitle($shortTitle)
{
$this->shortTitle = $shortTitle;

return $this;
}

/**
* @return array
*/
Expand Down
1 change: 1 addition & 0 deletions Manager/FormManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ public function save($data, $locale = null, $id = null)
$fieldTranslation->setTitle(self::getValue($fieldData, 'title'));
$fieldTranslation->setPlaceholder(self::getValue($fieldData, 'placeholder'));
$fieldTranslation->setDefaultValue(self::getValue($fieldData, 'defaultValue'));
$fieldTranslation->setShortTitle(self::getValue($fieldData, 'shortTitle'));


// Field Options
Expand Down
1 change: 1 addition & 0 deletions Resources/config/doctrine/FormFieldTranslation.orm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<field name="title" column="title" type="text" nullable="true"/>
<field name="placeholder" column="placeholder" type="string" length="255" nullable="true"/>
<field name="defaultValue" column="defaultValue" type="string" length="255" nullable="true"/>
<field name="shortTitle" column="shortTitle" type="string" length="255" nullable="true"/>
<field name="locale" column="locale" type="string" length="5"/>
<field name="options" column="options" type="text" nullable="true"/>

Expand Down
2 changes: 1 addition & 1 deletion Resources/doc/dynamic.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ form-notify.html.twig
{% endif %}

{% if value is not empty %}
<strong>{{ field.title|default('')|raw }}</strong>: {{ value }}<br>
<strong>{{ field.shortTitle|default(field.title)|raw }}</strong>: {{ value }}<br>
{% endif %}
{% endfor %}
```
Expand Down
8 changes: 8 additions & 0 deletions Resources/translations/sulu/backend.de.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,14 @@
<source>sulu_form.width.five-sixths</source>
<target>Fünf Sechstel</target>
</trans-unit>
<trans-unit id="78">
<source>sulu_form.short_title</source>
<target>Kurztitel</target>
</trans-unit>
<trans-unit id="79">
<source>sulu_form.short_title_description</source>
<target>Optionaler Titel des Feldes, z.B. in der Benachrichtigungs-Email.</target>
</trans-unit>
</body>
</file>
</xliff>
8 changes: 8 additions & 0 deletions Resources/translations/sulu/backend.en.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,14 @@
<source>sulu_form.width.five-sixths</source>
<target>five sixths</target>
</trans-unit>
<trans-unit id="78">
<source>sulu_form.short_title</source>
<target>Short title</target>
</trans-unit>
<trans-unit id="79">
<source>sulu_form.short_title_description</source>
<target>Optional title of field, for example in notification mail.</target>
</trans-unit>
</body>
</file>
</xliff>
8 changes: 8 additions & 0 deletions Resources/translations/sulu/backend.fr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,14 @@
<source>sulu_form.width.five-sixths</source>
<target>cinq sixièmes</target>
</trans-unit>
<trans-unit id="78">
<source>sulu_form.short_title</source>
<target>Titre abrégé</target>
</trans-unit>
<trans-unit id="79">
<source>sulu_form.short_title_description</source>
<target>Titre facultatif du champ dans la notification email p. ex.</target>
</trans-unit>
</body>
</file>
</xliff>
19 changes: 19 additions & 0 deletions Resources/views/forms/fields/default-field.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,25 @@
<div class="input-description"></div>
</div>
{% endblock %}

{% block short_title %}
<div class="grid-col-12 floating form-group">
<label for="short-title<~=index~>" class="pointer" title="Short Title">
<%= translate('sulu_form.short_title') %>
</label>

<input id="short-title<~=index~>"
data-property="shortTitle"
type="text"
class="form-element preview-update trigger-save-button"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should add maxlength attribute where it is limited in the database

maxlength="255"
data-mapper-property="shortTitle"/>

<div class="block-content" data-sort-mode-id="{{ blockId }}shortTitle<~=index~>"></div>

<div class="input-description"><%= translate('sulu_form.short_title_description') %></div>
</div>
{% endblock %}
</div>
</div>
{% endblock %}
Expand Down
2 changes: 2 additions & 0 deletions Resources/views/forms/fields/types/freetext.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

{% block required %}{% endblock %}

{% block short_title %}{% endblock %}

{% block placeholder_default %}
{% endblock %}

Expand Down
2 changes: 2 additions & 0 deletions Resources/views/forms/fields/types/headline.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

{% block required %}{% endblock %}

{% block short_title %}{% endblock %}

{% block placeholder_default %}
{% endblock %}

Expand Down
2 changes: 1 addition & 1 deletion Resources/views/forms/fields/types/spacer.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

{% block required %}{% endblock %}

{% block title %}{% endblock %}
{% block title_short_title %}{% endblock %}

{% block placeholder_default %}
{% endblock %}
Expand Down