Skip to content

Commit

Permalink
Remove title from image type
Browse files Browse the repository at this point in the history
  • Loading branch information
maximehuran committed Aug 10, 2024
1 parent 0a27263 commit 3363b92
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 21 deletions.
9 changes: 7 additions & 2 deletions src/Form/Type/ImageType.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,24 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
if (!$options['with_alignment']) {
$builder->remove('align');
}
if (!$options['with_title']) {
$builder->remove('title');
}
}

public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'with_link' => true,
'with_alignment' => true,
'with_link' => false,
'with_alignment' => false,
'with_title' => false,
'attr' => [
'class' => 'ui segment',
],
]);
$resolver->setAllowedTypes('with_link', ['null', 'bool']);
$resolver->setAllowedTypes('with_alignment', ['null', 'bool']);
$resolver->setAllowedTypes('with_title', ['null', 'bool']);
}

public function getParent(): string
Expand Down
2 changes: 1 addition & 1 deletion src/Form/Type/UiElement/LinksUiElementType.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Form\Extension\Core\Type\TextType;

#[AsUiElement(
code: 'monsieurbiz_ui_elements.links_ui_element',
Expand Down
4 changes: 0 additions & 4 deletions src/Form/Type/UiElement/LogosUiElementType.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
->add('logos', CollectionType::class, [
'label' => 'monsieurbiz_ui_elements.common.fields.logos',
'entry_type' => ImageType::class,
'entry_options' => [
'with_link' => false,
'with_alignment' => false,
],
'allow_add' => true,
'allow_delete' => true,
'constraints' => [new Assert\Valid()],
Expand Down
8 changes: 3 additions & 5 deletions src/Form/Type/UiElement/TextWithImageUiElementType.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,11 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
],
])
->add('image', ImageType::class, [
'label' => 'monsieurbiz_richeditor_plugin.ui_element.monsieurbiz.image.field.image',
'required' => true,
'with_link' => false,
'with_alignment' => false,
'label' => 'monsieurbiz_ui_elements.common.fields.image_with_text',
'required' => false,
])
->add('imageAlign', ChoiceType::class, [
'label' => 'monsieurbiz_ui_elements.common.fields.alignment',
'label' => 'monsieurbiz_ui_elements.common.fields.image_alignment',
'required' => true,
'choices' => [
'monsieurbiz_ui_elements.ui_element.text_with_image_ui_element.fields.image_align.choices.left' => self::IMAGE_POSITION_LEFT,
Expand Down
2 changes: 2 additions & 0 deletions src/Resources/translations/messages.en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ monsieurbiz_ui_elements:
author: "Author"
content: "Content"
image: "Image"
image_alignment: "Image alignment"
image_with_text: "Image with the text"
logos: "Logos"
ui_element:
hero_ui_element:
Expand Down
2 changes: 2 additions & 0 deletions src/Resources/translations/messages.fr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ monsieurbiz_ui_elements:
author: "Auteur"
content: "Contenu"
image: "Image"
image_alignment: "Alignement de l'image"
image_with_text: "Image accompagnant le texte"
logos: "Logos"
ui_element:
hero_ui_element:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ element fields:
- logos
- image
- alt
- title
#}

<div>
Expand All @@ -17,7 +16,7 @@ element fields:
<div class="ui grid">
{% for logo in element.logos %}
<div class="four wide column">
<img src="{{ logo.image|imagine_filter('monsieurbiz_sylius_ui_elements_logos') }}" alt="{{ logo.alt|default('') }}" title="{{ logo.title|default('') }}" width="180">
<img src="{{ logo.image|imagine_filter('monsieurbiz_sylius_ui_elements_logos') }}" alt="{{ logo.alt|default('') }}" width="180">
</div>
{% endfor %}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ element fields:
- image
- image
- alt
- title
- imageAlign
#}
{% set isRightAlign = (element.imageAlign|default('')) == constant('MonsieurBiz\\SyliusUiElementsPlugin\\Form\\Type\\UiElement\\TextWithImageUiElementType::IMAGE_POSITION_RIGHT') %}
Expand All @@ -15,7 +14,6 @@ element fields:
<img
src="{{ element.image.image|imagine_filter('monsieurbiz_sylius_ui_elements_text_with_image') }}"
alt="{{ element.image.alt|default('') }}"
title="{{ element.image.title|default('') }}"
class="ui image {{ isRightAlign ? 'right' : 'left' }} floated"
{% if isRightAlign %}style="margin-left: 10px; margin-bottom: 10px;"{% endif %}
{% if not isRightAlign %}style="margin-right: 10px; margin-bottom: 10px;"{% endif %}
Expand Down
5 changes: 2 additions & 3 deletions src/Resources/views/Shop/UiElement/logos_ui_element.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,17 @@ element fields:
- logos
- image
- alt
- title
#}

<div>
{% if element.title|default('') is not empty %}
<div class="ui huge header">{{ element.title }}</div>
<div class="ui divider hidden"></div>
{% endif %}
<div class="ui grid stackable">
<div class="ui grid">
{% for logo in element.logos %}
<div class="four wide column">
<img src="{{ logo.image|imagine_filter('monsieurbiz_sylius_ui_elements_logos') }}" alt="{{ logo.alt|default('') }}" title="{{ logo.title|default('') }}" width="180">
<img src="{{ logo.image|imagine_filter('monsieurbiz_sylius_ui_elements_logos') }}" alt="{{ logo.alt|default('') }}" width="180">
</div>
{% endfor %}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ element fields:
- image
- image
- alt
- title
- imageAlign
#}
{% set isRightAlign = (element.imageAlign|default('')) == constant('MonsieurBiz\\SyliusUiElementsPlugin\\Form\\Type\\UiElement\\TextWithImageUiElementType::IMAGE_POSITION_RIGHT') %}
Expand All @@ -15,7 +14,6 @@ element fields:
<img
src="{{ element.image.image|imagine_filter('monsieurbiz_sylius_ui_elements_text_with_image') }}"
alt="{{ element.image.alt|default('') }}"
title="{{ element.image.title|default('') }}"
class="ui image {{ isRightAlign ? 'right' : 'left' }} floated"
{% if isRightAlign %}style="margin-left: 10px; margin-bottom: 10px;"{% endif %}
{% if not isRightAlign %}style="margin-right: 10px; margin-bottom: 10px;"{% endif %}
Expand Down

0 comments on commit 3363b92

Please sign in to comment.