replace is_image with file_type in form types
This commit is contained in:
parent
cf33f4b5a3
commit
c1e7e3ddf0
|
@ -29,7 +29,7 @@ class FileBlockType extends TextBlockType
|
||||||
public function buildView(FormView $view, FormInterface $form, array $options)
|
public function buildView(FormView $view, FormInterface $form, array $options)
|
||||||
{
|
{
|
||||||
$view->vars = array_replace($view->vars, [
|
$view->vars = array_replace($view->vars, [
|
||||||
'is_image' => $options['is_image'],
|
'file_type' => $options['file_type'],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ class FileBlockType extends TextBlockType
|
||||||
{
|
{
|
||||||
$resolver->setDefaults([
|
$resolver->setDefaults([
|
||||||
'data_class' => FileBlock::class,
|
'data_class' => FileBlock::class,
|
||||||
'is_image' => false,
|
'file_type' => 'auto',
|
||||||
'options' => [],
|
'options' => [],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,10 +11,15 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
{% set value = form.vars.data %}
|
{% set value = form.vars.data %}
|
||||||
{% set isImage = form.parent.vars.is_image is defined and form.parent.vars.is_image %}
|
|
||||||
|
{% if form.parent.vars.file_type is defined %}
|
||||||
|
{% set fileType = form.parent.vars.file_type %}
|
||||||
|
{% else %}
|
||||||
|
{% set fileType = 'auto' %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% if value %}
|
{% if value %}
|
||||||
{% if isImage and value and value.extension in ['jpeg', 'jpg', 'gif', 'png', 'svg'] %}
|
{% if fileType in ['auto', 'image'] and value.extension in ['jpeg', 'jpg', 'gif', 'png', 'svg'] %}
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-img-top bg-tiles text-center">
|
<div class="card-img-top bg-tiles text-center">
|
||||||
<a href="{{ asset(value.pathname) }}" target="_blank">
|
<a href="{{ asset(value.pathname) }}" target="_blank">
|
||||||
|
|
Loading…
Reference in a new issue