-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic support for editing through eZ Platform Admin UI (#30)
- Loading branch information
Showing
4 changed files
with
81 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace eZ\Publish\Core\FieldType\XmlText; | ||
|
||
use EzSystems\RepositoryForms\Data\Content\FieldData; | ||
use EzSystems\RepositoryForms\FieldType\FieldValueFormMapperInterface; | ||
use Symfony\Component\Form\FormInterface; | ||
|
||
class FormMapper implements FieldValueFormMapperInterface | ||
{ | ||
public function mapFieldValueForm(FormInterface $fieldForm, FieldData $data) | ||
{ | ||
$fieldForm | ||
->add( | ||
$fieldForm->getConfig()->getFormFactory()->createBuilder() | ||
->create( | ||
'value', | ||
FormType::class, | ||
array( | ||
'required' => $data->fieldDefinition->isRequired, | ||
'label' => $data->fieldDefinition->getName(), | ||
) | ||
) | ||
->setAutoInitialize(false) | ||
->getForm() | ||
); | ||
} | ||
} |
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,38 @@ | ||
<?php | ||
|
||
namespace eZ\Publish\Core\FieldType\XmlText; | ||
|
||
use eZ\Publish\API\Repository\FieldTypeService; | ||
use EzSystems\RepositoryForms\FieldType\DataTransformer\FieldValueTransformer; | ||
use Symfony\Component\Form\AbstractType; | ||
use Symfony\Component\Form\Extension\Core\Type\TextareaType; | ||
use Symfony\Component\Form\FormBuilderInterface; | ||
|
||
class FormType extends AbstractType | ||
{ | ||
/** | ||
* @var \eZ\Publish\API\Repository\FieldTypeService | ||
*/ | ||
private $fieldTypeService; | ||
|
||
public function __construct(FieldTypeService $fieldTypeService) | ||
{ | ||
$this->fieldTypeService = $fieldTypeService; | ||
} | ||
|
||
public function buildForm(FormBuilderInterface $builder, array $options) | ||
{ | ||
$builder | ||
->add('xml', TextareaType::class, array('attr' => array('rows' => 10))) | ||
->addModelTransformer( | ||
new FieldValueTransformer( | ||
$this->fieldTypeService->getFieldType('ezxmltext') | ||
) | ||
); | ||
} | ||
|
||
public function getBlockPrefix() | ||
{ | ||
return 'ezplatform_fieldtype_ezxmltext'; | ||
} | ||
} |
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