mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 17:10:53 +00:00
[AdminBundle] Add LiveComponent for Customer
This commit is contained in:
parent
3972679551
commit
df68562f9c
7 changed files with 69 additions and 4 deletions
|
|
@ -14,7 +14,6 @@ declare(strict_types=1);
|
|||
namespace Sylius\Bundle\AdminBundle\Form\Type;
|
||||
|
||||
use Sylius\Bundle\AdminBundle\Form\EventSubscriber\AddUserFormSubscriber;
|
||||
use Sylius\Bundle\CoreBundle\Form\Type\User\ShopUserType;
|
||||
use Sylius\Bundle\CustomerBundle\Form\Type\CustomerType as BaseCustomerType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
|
|
|
|||
42
src/Sylius/Bundle/AdminBundle/Form/Type/ShopUserType.php
Normal file
42
src/Sylius/Bundle/AdminBundle/Form/Type/ShopUserType.php
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Sylius Sp. z o.o.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sylius\Bundle\AdminBundle\Form\Type;
|
||||
|
||||
use Sylius\Bundle\CoreBundle\Form\Type\User\ShopUserType as BaseShopUserType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
final class ShopUserType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->add('plainPassword', PasswordType::class, [
|
||||
'label' => 'sylius.form.user.password.label',
|
||||
'always_empty' => false,
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
public function getBlockPrefix(): string
|
||||
{
|
||||
return 'sylius_admin_shop_user';
|
||||
}
|
||||
|
||||
public function getParent(): string
|
||||
{
|
||||
return BaseShopUserType::class;
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,11 @@ sylius_twig_hooks:
|
|||
hooks:
|
||||
'sylius_admin.customer.create.content':
|
||||
form:
|
||||
template: '@SyliusAdmin/shared/crud/common/content/form.html.twig'
|
||||
component: 'sylius_admin:customer:form'
|
||||
props:
|
||||
resource: '@=_context.resource'
|
||||
form: '@=_context.form'
|
||||
template: '@SyliusAdmin/shared/crud/common/content/form.html.twig'
|
||||
configuration:
|
||||
render_rest: false
|
||||
priority: 0
|
||||
|
|
|
|||
|
|
@ -2,7 +2,11 @@ sylius_twig_hooks:
|
|||
hooks:
|
||||
'sylius_admin.customer.update.content':
|
||||
form:
|
||||
template: '@SyliusAdmin/shared/crud/common/content/form.html.twig'
|
||||
component: 'sylius_admin:customer:form'
|
||||
props:
|
||||
resource: '@=_context.resource'
|
||||
form: '@=_context.form'
|
||||
template: '@SyliusAdmin/shared/crud/common/content/form.html.twig'
|
||||
configuration:
|
||||
render_rest: false
|
||||
priority: 0
|
||||
|
|
|
|||
|
|
@ -253,6 +253,10 @@
|
|||
<tag name="form.type" />
|
||||
</service>
|
||||
|
||||
<service id="sylius_admin.form.type.shop_user" class="Sylius\Bundle\AdminBundle\Form\Type\ShopUserType" >
|
||||
<tag name="form.type" />
|
||||
</service>
|
||||
|
||||
<service id="sylius_admin.form.type.tax_category" class="Sylius\Bundle\AdminBundle\Form\Type\TaxCategoryType" >
|
||||
<tag name="form.type" />
|
||||
</service>
|
||||
|
|
|
|||
|
|
@ -77,6 +77,18 @@
|
|||
<tag name="sylius.live_component.admin" key="sylius_admin:currency:form" />
|
||||
</service>
|
||||
|
||||
<service
|
||||
id="sylius_admin.twig.component.customer.form"
|
||||
class="Sylius\Bundle\UiBundle\Twig\Component\ResourceFormComponent"
|
||||
>
|
||||
<argument type="service" id="sylius.repository.customer" />
|
||||
<argument type="service" id="form.factory" />
|
||||
<argument>%sylius.model.customer.class%</argument>
|
||||
<argument>Sylius\Bundle\AdminBundle\Form\Type\CustomerType</argument>
|
||||
|
||||
<tag name="sylius.live_component.admin" key="sylius_admin:customer:form" />
|
||||
</service>
|
||||
|
||||
<service
|
||||
id="sylius_admin.twig.component.customer_group.form"
|
||||
class="Sylius\Bundle\UiBundle\Twig\Component\ResourceFormComponent"
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
{% if (hookable_metadata.context.form.vars.value.user is null) %}
|
||||
{% if (hookable_metadata.context.resource.user.id|default(null) is null) %}
|
||||
<div class="alert alert-info">
|
||||
{{ 'sylius.ui.account_credentials_details'|trans }}
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue