/**
  * Create the edit mask.
  *
  * @return string
  *
  * @throws DcGeneralRuntimeException         If the data container is not editable, closed.
  *
  * @throws DcGeneralInvalidArgumentException If an unknown property is encountered in the palette.
  */
 public function execute()
 {
     $inputProvider = $this->environment->getInputProvider();
     $palettesDefinition = $this->definition->getPalettesDefinition();
     $isSubmitted = $inputProvider->getValue('FORM_SUBMIT') === $this->definition->getName();
     $isAutoSubmit = $inputProvider->getValue('SUBMIT_TYPE') === 'auto';
     $widgetManager = new WidgetManager($this->environment, $this->model);
     $this->dispatcher->dispatch(PreEditModelEvent::NAME, new PreEditModelEvent($this->environment, $this->model));
     $this->enforceModelRelationship();
     // Pass 1: Get the palette for the values stored in the model.
     $palette = $palettesDefinition->findPalette($this->model);
     $propertyValues = $this->processInput($widgetManager);
     if ($isSubmitted && $propertyValues) {
         // Pass 2: Determine the real palette we want to work on if we have some data submitted.
         $palette = $palettesDefinition->findPalette($this->model, $propertyValues);
         // Update the model - the model might add some more errors to the propertyValueBag via exceptions.
         $this->environment->getController()->updateModelFromPropertyBag($this->model, $propertyValues);
     }
     $fieldSets = $this->buildFieldSet($widgetManager, $palette, $propertyValues);
     $buttons = $this->getEditButtons();
     if (!$isAutoSubmit && $isSubmitted && empty($this->errors)) {
         $this->doPersist();
         $this->handleSubmit($buttons);
     }
     $template = new ViewTemplate('dcfe_general_edit');
     $template->setData(array('fieldsets' => $fieldSets, 'subHeadline' => $this->getHeadline(), 'table' => $this->definition->getName(), 'enctype' => 'multipart/form-data', 'error' => $this->errors, 'editButtons' => $buttons));
     return $template->parse();
 }