/** * Returns an instance of self with data from the input form. * * @param ymcDatatypeEnhancedSelectionClassForm $form The userinput. * * @todo Do we need to check, if identifiers are unique? * * @return ymcDatatypeEnhancedSelectionClassContent */ public static function createFromForm(ymcDatatypeEnhancedSelectionClassForm $form) { $content = new self(); $content->isMultipleSelection = $form->hasValidData('ismultiple_value'); $content->isRemovalForbidden = $form->hasValidData('donotallowremoval_value'); $content->isNodePlacement = $form->hasValidData('isnodeplacement_value'); $content->delimiter = $form->getDataOrNull('delimiter'); $button = $form->getPressedButton(); // Tell the method, if it should return options marked for removal. $content->options = self::getOptionsFromForm($form, 'removeoption_button' === $button); switch ($button) { // removeoption has already been handled in getOptionsFromForm. case 'newoption_button': $content->addNewOption(); break; // case 'sort': // // break; // case 'sort': // // break; default: // There should not be any other case. break; } return $content; }