Skip to content

Commit

Permalink
EZP-29508: As an editor I want to manage ALT field with an image asse…
Browse files Browse the repository at this point in the history
…t field type (ezsystems#254)
  • Loading branch information
adamwojs authored and Łukasz Serwatka committed Sep 20, 2018
1 parent 22d9d75 commit 9708389
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
5 changes: 5 additions & 0 deletions bundle/Resources/translations/ezrepoforms_fieldtype.en.xlf
Expand Up @@ -61,6 +61,11 @@
<target>Width</target>
<note>key: content.field_type.ezmedia.width</note>
</trans-unit>
<trans-unit id="56f2bad53d241371a48f88accc3ef08a9bc643b6" resname="content.field_type.ezimageasset.alternative_text">
<source>Alternative text</source>
<target>Alternative text</target>
<note>key: content.field_type.ezimageasset.alternative_text</note>
</trans-unit>
</body>
</file>
</xliff>
7 changes: 5 additions & 2 deletions lib/FieldType/DataTransformer/ImageAssetValueTransformer.php
Expand Up @@ -35,7 +35,10 @@ public function transform($value): ?array

return array_merge(
$this->getDefaultProperties(),
['destinationContentId' => $value->destinationContentId]
[
'destinationContentId' => $value->destinationContentId,
'alternativeText' => $value->alternativeText,
]
);
}

Expand All @@ -58,6 +61,6 @@ public function reverseTransform($value): ?Value
);
}

return new Value($value['destinationContentId']);
return new Value($value['destinationContentId'], $value['alternativeText']);
}
}
8 changes: 8 additions & 0 deletions lib/Form/Type/FieldType/ImageAssetFieldType.php
Expand Up @@ -16,6 +16,7 @@
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\FileType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
Expand Down Expand Up @@ -80,6 +81,13 @@ public function buildForm(FormBuilderInterface $builder, array $options)
],
'mapped' => false,
]
)
->add(
'alternativeText',
TextType::class,
[
'label' => /** @Desc("Alternative text") */ 'content.field_type.ezimageasset.alternative_text',
]
);
}

Expand Down

0 comments on commit 9708389

Please sign in to comment.