-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: finalize the link modal (#864)
- Loading branch information
Showing
6 changed files
with
69 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 12 additions & 1 deletion
13
EMS/admin-ui-bundle/src/Resources/views/bootstrap5/modal/link.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,12 @@ | ||
{{ form(form) }} | ||
{% trans_default_domain 'ems-adminui-twigs' %} | ||
{{ form_start(form) }} | ||
{{ form_errors(form) }} | ||
{% for field in form.children|filter(f => f.vars.name != 'submit') %} | ||
{{ form_row(field) }} | ||
{% endfor %} | ||
<div class="btn-group"> | ||
{{ form_widget(form.submit) }} | ||
<button type="button" class="btn btn-default" data-bs-dismiss="modal">{{ 'core.modal.close'|trans }}</button> | ||
</div> | ||
{{ form_end(form) }} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace EMS\CoreBundle\Form\Form; | ||
|
||
use Symfony\Component\Form\ChoiceList\Loader\AbstractChoiceLoader; | ||
|
||
class AnchorChoiceLoader extends AbstractChoiceLoader | ||
{ | ||
/** | ||
* @param string[] $choices | ||
*/ | ||
public function __construct(private array $choices) | ||
{ | ||
} | ||
|
||
public function addAnchor(string $anchor): void | ||
{ | ||
if (\in_array($anchor, $this->choices)) { | ||
return; | ||
} | ||
$label = $anchor; | ||
if (\str_starts_with($label, '#')) { | ||
$label = \substr($label, 1); | ||
} | ||
$this->choices = \array_merge([$label => $anchor], $this->choices); | ||
} | ||
|
||
/** | ||
* @return array<string, string> | ||
*/ | ||
protected function loadChoices(): iterable | ||
{ | ||
return $this->choices; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters