OJS Need to change field type from FieldRichTextarea to FieldTextarea in e.g Masthead form

To achieve this, I follow the example ‘Add Custom Fields’ (Example - Add Custom Fields - Plugin Guide for OJS and OMP)
And the steps to follow are:

  1. create a field ‘FieldTextarea’ with the same parameters as the field I want to replace and with a temporary name (addField funtion)
  2. Remove the original field (removeField function)
  3. Change the temporary name to the correct name

But it doesn´t work, every time I remove the field, the build.js can’t retrieve the form.
Bellow is the code I’m using
Thank you

// Capturamos el evento ‘Form::config::before’
// para hacer modify (add->remove) de aquellos campos ‘FieldRichTextarea’
// que necesitamos se pasen a FieldText
// en función de que formulario se trate se cambiarán las campos correspondientes
HookRegistry::register(‘Form::config::before’, array($this, ‘modifyFormFields’));

  • Extiende forms to modify (add-remove)
    public function modifyFormFields($hookName, $form) {
    // Only modify the masthead form
    if (!defined(‘FORM_MASTHEAD’) || $form->id !== FORM_MASTHEAD) {
    // Don’t do anything at the site-wide level
    $context = Application::getRequest()->getContext();
    if (!$context) {
    // Modifica el campo
    // primero lo crea con un name temporal en la posición anterior al original
    $form->addField(new \PKP\components\forms\FieldTextarea(‘description_temp’, [
    ‘label’ => __(‘manager.setup.contextSummary’),
    ‘isMultilingual’ => true,
    ‘groupId’ => ‘keyInfo’,
    ‘value’ => $context ? $context->getData(‘description’) : null,
    ]), [FIELD_POSITION_BEFORE, ‘description’]);
    // segundo elimina el campo original
    // tercero cambia el id al original

Never mind
I found the solution. It was in the sequence:
First: remove the field
Second: create a new one, but it has to be with a temporary name
Third: rename it to the original name
Thank you anyway