Skip to content

Commit

Permalink
KUN-8981 | (fix) set internal as default option
Browse files Browse the repository at this point in the history
  • Loading branch information
mart-insiders committed Sep 30, 2024
1 parent 2d49e45 commit 1e616c4
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ public function transform($value): array

if ($value === null) {
return [
'link_type' => URLChooserType::EXTERNAL,
'link_type' => URLChooserType::INTERNAL,
'link_url' => null,
];
}

$linkType = $this->getLinkType($value);

return array_merge($this->getChoiceOption($linkType, $value), [
'link_type' => $linkType,
'link_url' => $value,
Expand Down Expand Up @@ -72,7 +73,7 @@ private function getLinkType(mixed $value): string

private function getChoiceOption(string $linkType, string $value): array
{
return match($linkType) {
return match ($linkType) {
URLChooserType::INTERNAL => ['choice_internal' => ['input' => $value]],
URLChooserType::EXTERNAL => ['choice_external' => $value],
URLChooserType::EMAIL => ['choice_email' => $value],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

class InternalURLSelectorType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->add('input', HiddenType::class, [
'label' => false,
Expand All @@ -23,7 +23,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
]);
}

public function getBlockPrefix()
public function getBlockPrefix(): string
{
return 'internal_url_selector';
}
Expand Down
2 changes: 1 addition & 1 deletion src/Kunstmaan/NodeBundle/Form/Type/URLChooserType.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public function buildView(FormView $view, FormInterface $form, array $options)

private function getLinkTypeExpression(string $type): string
{
return 'this.getParent().get("link_type").getData() === "'.$type.'"';
return 'this.getParent().get("link_type").getData() === "' . $type . '"';
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Kunstmaan/NodeBundle/Form/Type/URLTypeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function configureOptions(OptionsResolver $resolver): void
$resolver->setAllowedTypes('choices', 'array');
}

public function buildView(FormView $view, FormInterface $form, array $options)
public function buildView(FormView $view, FormInterface $form, array $options): void
{
$view->vars['choices'] = $options['choices'];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,16 @@
<input type="hidden" name="{{ linkUrl.full_name }}" value="{{ linkUrl.value ? linkUrl.value : '' }}" id="{{ linkUrl.id }}" class="form-control {% if linkUrl.attr is defined and linkUrl.attr.class is defined %}{{ linkUrl.attr.class }}{% endif %}">
<input type="text" disabled="disabled" class="form-control js-urlchooser-value" value="{{ linkUrl.value ? linkUrl.value|replace_url : '' }}">
<span class="input-group-btn">
<button type="button" class="btn btn-default btn--raise-on-hover" data-toggle="modal" data-target="#{{ linkUrl.id }}-urlChooserModal" data-link="{{ path('KunstmaanNodeBundle_selecturl') }}">
{{ 'kuma_node.widget.choose' | trans }}
</button>
</span>
<button type="button" class="btn btn-default btn--raise-on-hover" data-toggle="modal" data-target="#{{ linkUrl.id }}-urlChooserModal" data-link="{{ path('KunstmaanNodeBundle_selecturl') }}">
{{ 'kuma_node.widget.choose' | trans }}
</button>
</span>
{% else %}
<input type="text" name="{{ linkUrl.full_name }}" value="{{ linkUrl.value ? linkUrl.value : '' }}" id="{{ linkUrl.id }}" class="form-control {% if linkUrl.attr is defined and linkUrl.attr.class is defined %}{{ linkUrl.attr.class }}{% endif %}"{% if linkUrl.attr is defined and linkUrl.attr.placeholder is defined %} placeholder="{{ linkUrl.attr.placeholder }}"{% endif %}>
{% endif %}
</div>
</div>
</div>

</div>
{% else %}
{% set linkUrl = form.link_url.vars %}
Expand Down

0 comments on commit 1e616c4

Please sign in to comment.