OJS 3.2.1.1 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) {
    return;
    }
    // Don’t do anything at the site-wide level
    $context = Application::getRequest()->getContext();
    if (!$context) {
    return;
    }
    // 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
    $form->removeField(‘description’);
    // tercero cambia el id al original
    $form->getField(‘description_temp’)->name=‘description’;
    }

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