Skip to content

Commit

Permalink
feat(LinkType): Add a new form type LinkType that should be used for …
Browse files Browse the repository at this point in the history
…urls
  • Loading branch information
Etienne Gutbub committed Oct 8, 2024
1 parent 168a4c3 commit abd70ec
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
24 changes: 24 additions & 0 deletions src/Form/Type/LinkType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

/*
* This file is part of Monsieur Biz' Rich Editor plugin for Sylius.
*
* (c) Monsieur Biz <[email protected]>
*
* For the full copyright and license information, please view the LICENSE.txt
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace MonsieurBiz\SyliusRichEditorPlugin\Form\Type;

use Symfony\Component\Form\Extension\Core\Type\TextType;

final class LinkType extends TextType
{
/**
* At the moment just like a TextType but in addition with the Plugin Monsieurbiz/SyliusMenuPlugin
* it will allow us to add a button to choose the target of the link on all rich editor fields that should have an URL.
*/
}
4 changes: 2 additions & 2 deletions src/Form/Type/UiElement/ButtonLinkType.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@

use MonsieurBiz\SyliusRichEditorPlugin\Form\Type\AlignmentType;
use MonsieurBiz\SyliusRichEditorPlugin\Form\Type\LevelType;
use MonsieurBiz\SyliusRichEditorPlugin\Form\Type\LinkType;
use MonsieurBiz\SyliusRichEditorPlugin\Form\Type\LinkTypeType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\TextType as FormTextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints as Assert;
Expand Down Expand Up @@ -69,7 +69,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
'label' => 'monsieurbiz_richeditor_plugin.ui_element.monsieurbiz.button.field.label',
'constraints' => $constraintsLabel,
])
->add('link', TextType::class, [
->add('link', LinkType::class, [
'required' => $required,
'label' => 'monsieurbiz_richeditor_plugin.ui_element.monsieurbiz.button.field.link',
'constraints' => $constraintsLink,
Expand Down
4 changes: 2 additions & 2 deletions src/Form/Type/UiElement/ImageType.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
use MonsieurBiz\SyliusMediaManagerPlugin\Form\Type\ImageType as MediaManagerImageType;
use MonsieurBiz\SyliusRichEditorPlugin\Form\Constraints\RichEditorConstraints;
use MonsieurBiz\SyliusRichEditorPlugin\Form\Type\AlignmentType;
use MonsieurBiz\SyliusRichEditorPlugin\Form\Type\LinkType;
use MonsieurBiz\SyliusRichEditorPlugin\Form\Type\LinkTypeType;
use MonsieurBiz\SyliusRichEditorPlugin\MonsieurBizSyliusRichEditorPlugin;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\FileType;
use Symfony\Component\Form\Extension\Core\Type\TextType as FormTextType;
use Symfony\Component\Form\Extension\Core\Type\UrlType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
Expand Down Expand Up @@ -58,7 +58,7 @@ public function addFields(FormBuilderInterface $builder, array $options): void
'required' => false,
'label' => 'monsieurbiz_richeditor_plugin.ui_element.monsieurbiz.image.field.title',
])
->add('link', UrlType::class, [
->add('link', LinkType::class, [
'required' => false,
'label' => 'monsieurbiz_richeditor_plugin.ui_element.monsieurbiz.image.field.link',
'constraints' => [
Expand Down

0 comments on commit abd70ec

Please sign in to comment.