reformat edit forms (#1192)
This commit is contained in:
@@ -43,6 +43,7 @@ trait EntityFormTrait
|
|||||||
])
|
])
|
||||||
->add('timeBudget', DurationType::class, [
|
->add('timeBudget', DurationType::class, [
|
||||||
'label' => 'label.timeBudget',
|
'label' => 'label.timeBudget',
|
||||||
|
'icon' => 'clock',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
])
|
])
|
||||||
;
|
;
|
||||||
|
|||||||
47
src/Form/Extension/IconExtension.php
Normal file
47
src/Form/Extension/IconExtension.php
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Kimai time-tracking app.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Form\Extension;
|
||||||
|
|
||||||
|
use Symfony\Component\Form\AbstractTypeExtension;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||||
|
use Symfony\Component\Form\FormInterface;
|
||||||
|
use Symfony\Component\Form\FormView;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows to register custom icons at form fields
|
||||||
|
*/
|
||||||
|
class IconExtension extends AbstractTypeExtension
|
||||||
|
{
|
||||||
|
public static function getExtendedTypes(): iterable
|
||||||
|
{
|
||||||
|
return [TextType::class];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param FormView $view
|
||||||
|
* @param FormInterface $form
|
||||||
|
* @param array $options
|
||||||
|
*/
|
||||||
|
public function buildView(FormView $view, FormInterface $form, array $options)
|
||||||
|
{
|
||||||
|
$view->vars['icon'] = $options['icon'] ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param OptionsResolver $resolver
|
||||||
|
*/
|
||||||
|
public function configureOptions(OptionsResolver $resolver)
|
||||||
|
{
|
||||||
|
$resolver->setDefined(['icon']);
|
||||||
|
$resolver->setAllowedTypes('icon', 'string');
|
||||||
|
$resolver->setDefault('icon', '');
|
||||||
|
}
|
||||||
|
}
|
||||||
35
src/Form/Type/AvatarType.php
Normal file
35
src/Form/Type/AvatarType.php
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Kimai time-tracking app.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Form\Type;
|
||||||
|
|
||||||
|
use Symfony\Component\Form\AbstractType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
|
class AvatarType extends AbstractType
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function configureOptions(OptionsResolver $resolver)
|
||||||
|
{
|
||||||
|
$resolver->setDefaults([
|
||||||
|
'label' => 'label.avatar',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getParent()
|
||||||
|
{
|
||||||
|
return TextType::class;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,6 +10,7 @@
|
|||||||
namespace App\Form;
|
namespace App\Form;
|
||||||
|
|
||||||
use App\Entity\User;
|
use App\Entity\User;
|
||||||
|
use App\Form\Type\AvatarType;
|
||||||
use App\Form\Type\YesNoType;
|
use App\Form\Type\YesNoType;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\EmailType;
|
use Symfony\Component\Form\Extension\Core\Type\EmailType;
|
||||||
@@ -36,8 +37,7 @@ class UserEditType extends AbstractType
|
|||||||
'label' => 'label.title',
|
'label' => 'label.title',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
])
|
])
|
||||||
->add('avatar', TextType::class, [
|
->add('avatar', AvatarType::class, [
|
||||||
'label' => 'label.avatar',
|
|
||||||
'required' => false,
|
'required' => false,
|
||||||
])
|
])
|
||||||
->add('email', EmailType::class, [
|
->add('email', EmailType::class, [
|
||||||
|
|||||||
@@ -6,9 +6,52 @@
|
|||||||
{% block page_actions %}{{ actions.activity(activity, 'edit') }}{% endblock %}
|
{% block page_actions %}{{ actions.activity(activity, 'edit') }}{% endblock %}
|
||||||
|
|
||||||
{% block main %}
|
{% block main %}
|
||||||
{{ include(app.request.xmlHttpRequest ? 'default/_form_modal.html.twig' : 'default/_form.html.twig', {
|
{% set formEditTemplate = app.request.xmlHttpRequest ? 'default/_form_modal.html.twig' : 'default/_form.html.twig' %}
|
||||||
|
{% set formOptions = {
|
||||||
'title': activity.name|default('create'|trans),
|
'title': activity.name|default('create'|trans),
|
||||||
'form': form,
|
'form': form,
|
||||||
'back': path('admin_activity')
|
'back': path('admin_activity')
|
||||||
}) }}
|
} %}
|
||||||
|
{% embed formEditTemplate with formOptions %}
|
||||||
|
{% block form_body %}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-10">
|
||||||
|
{{ form_row(form.name) }}
|
||||||
|
</div>
|
||||||
|
<div class="col-md-2">
|
||||||
|
{{ form_row(form.color) }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{{ form_row(form.comment) }}
|
||||||
|
{{ form_row(form.customer) }}
|
||||||
|
{{ form_row(form.project) }}
|
||||||
|
<fieldset>
|
||||||
|
{#<legend>Financial data</legend>#}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6">
|
||||||
|
{{ form_row(form.fixedRate) }}
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6">
|
||||||
|
{{ form_row(form.hourlyRate) }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6">
|
||||||
|
{{ form_row(form.budget) }}
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6">
|
||||||
|
{{ form_row(form.timeBudget) }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
{{ form_row(form.visible) }}
|
||||||
|
{% if form.metaFields is defined and form.metaFields is not empty %}
|
||||||
|
<fieldset>
|
||||||
|
{#<legend>Custom fields</legend>#}
|
||||||
|
{{ form_row(form.metaFields) }}
|
||||||
|
</fieldset>
|
||||||
|
{% endif %}
|
||||||
|
{{ form_widget(form) }}
|
||||||
|
{% endblock %}
|
||||||
|
{% endembed %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -6,9 +6,91 @@
|
|||||||
{% block page_actions %}{{ actions.customer(customer, 'edit') }}{% endblock %}
|
{% block page_actions %}{{ actions.customer(customer, 'edit') }}{% endblock %}
|
||||||
|
|
||||||
{% block main %}
|
{% block main %}
|
||||||
{{ include(app.request.xmlHttpRequest ? 'default/_form_modal.html.twig' : 'default/_form.html.twig', {
|
{% set formEditTemplate = app.request.xmlHttpRequest ? 'default/_form_modal.html.twig' : 'default/_form.html.twig' %}
|
||||||
|
{% set formOptions = {
|
||||||
'title': customer.name|default('create'|trans),
|
'title': customer.name|default('create'|trans),
|
||||||
'form': form,
|
'form': form,
|
||||||
'back': path('admin_customer')
|
'back': path('admin_customer')
|
||||||
}) }}
|
} %}
|
||||||
|
{% embed formEditTemplate with formOptions %}
|
||||||
|
{% block form_body %}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-10">
|
||||||
|
{{ form_row(form.name) }}
|
||||||
|
</div>
|
||||||
|
<div class="col-md-2">
|
||||||
|
{{ form_row(form.color) }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{{ form_row(form.comment) }}
|
||||||
|
<fieldset>
|
||||||
|
{#<legend>Company data</legend>#}
|
||||||
|
{{ form_row(form.company) }}
|
||||||
|
{{ form_row(form.address) }}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-4">
|
||||||
|
{{ form_row(form.country) }}
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4">
|
||||||
|
{{ form_row(form.currency) }}
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4">
|
||||||
|
{{ form_row(form.timezone) }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
<fieldset>
|
||||||
|
{#<legend>Contact data</legend>#}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-4">
|
||||||
|
{{ form_row(form.contact) }}
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4">
|
||||||
|
{{ form_row(form.email) }}
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4">
|
||||||
|
{{ form_row(form.homepage) }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-4">
|
||||||
|
{{ form_row(form.mobile) }}
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4">
|
||||||
|
{{ form_row(form.phone) }}
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4">
|
||||||
|
{{ form_row(form.fax) }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
<fieldset>
|
||||||
|
{#<legend>Financial data</legend>#}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6">
|
||||||
|
{{ form_row(form.fixedRate) }}
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6">
|
||||||
|
{{ form_row(form.hourlyRate) }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6">
|
||||||
|
{{ form_row(form.budget) }}
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6">
|
||||||
|
{{ form_row(form.timeBudget) }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
{{ form_row(form.visible) }}
|
||||||
|
{% if form.metaFields is defined and form.metaFields is not empty %}
|
||||||
|
<fieldset>
|
||||||
|
{#<legend>Custom fields</legend>#}
|
||||||
|
{{ form_row(form.metaFields) }}
|
||||||
|
</fieldset>
|
||||||
|
{% endif %}
|
||||||
|
{{ form_widget(form) }}
|
||||||
|
{% endblock %}
|
||||||
|
{% endembed %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -32,3 +32,16 @@
|
|||||||
{{ block('form_widget_simple') }}
|
{{ block('form_widget_simple') }}
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
{%- endblock datetime_widget %}
|
{%- endblock datetime_widget %}
|
||||||
|
|
||||||
|
{% block text_widget -%}
|
||||||
|
{% if icon is not empty %}
|
||||||
|
<div class="input-group">
|
||||||
|
<div class="input-group-addon">
|
||||||
|
<i class="{{ icon|icon }}"></i>
|
||||||
|
</div>
|
||||||
|
{{ block('form_widget_simple') }}
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
|
{{ block('form_widget_simple') }}
|
||||||
|
{% endif %}
|
||||||
|
{%- endblock text_widget %}
|
||||||
|
|||||||
@@ -6,9 +6,59 @@
|
|||||||
{% block page_actions %}{{ actions.project(project, 'edit') }}{% endblock %}
|
{% block page_actions %}{{ actions.project(project, 'edit') }}{% endblock %}
|
||||||
|
|
||||||
{% block main %}
|
{% block main %}
|
||||||
{{ include(app.request.xmlHttpRequest ? 'default/_form_modal.html.twig' : 'default/_form.html.twig', {
|
{% set formEditTemplate = app.request.xmlHttpRequest ? 'default/_form_modal.html.twig' : 'default/_form.html.twig' %}
|
||||||
|
{% set formOptions = {
|
||||||
'title': project.name|default('create'|trans),
|
'title': project.name|default('create'|trans),
|
||||||
'form': form,
|
'form': form,
|
||||||
'back': path('admin_project')
|
'back': path('admin_project')
|
||||||
}) }}
|
} %}
|
||||||
|
{% embed formEditTemplate with formOptions %}
|
||||||
|
{% block form_body %}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-10">
|
||||||
|
{{ form_row(form.name) }}
|
||||||
|
</div>
|
||||||
|
<div class="col-md-2">
|
||||||
|
{{ form_row(form.color) }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{{ form_row(form.comment) }}
|
||||||
|
{{ form_row(form.customer) }}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6">
|
||||||
|
{{ form_row(form.orderNumber) }}
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6">
|
||||||
|
{{ form_row(form.orderDate) }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<fieldset>
|
||||||
|
{#<legend>Financial data</legend>#}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6">
|
||||||
|
{{ form_row(form.fixedRate) }}
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6">
|
||||||
|
{{ form_row(form.hourlyRate) }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6">
|
||||||
|
{{ form_row(form.budget) }}
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6">
|
||||||
|
{{ form_row(form.timeBudget) }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
{{ form_row(form.visible) }}
|
||||||
|
{% if form.metaFields is defined and form.metaFields is not empty %}
|
||||||
|
<fieldset>
|
||||||
|
{#<legend>Custom fields</legend>#}
|
||||||
|
{{ form_row(form.metaFields) }}
|
||||||
|
</fieldset>
|
||||||
|
{% endif %}
|
||||||
|
{{ form_widget(form) }}
|
||||||
|
{% endblock %}
|
||||||
|
{% endembed %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
Reference in New Issue
Block a user