elementCount(); $i++) { $inputElement = $form->getElementAt($i); if ($inputElement instanceof InputElement) { $i = self::toBootStrapInputElementAndGetNewLoopingPosition($form, $i, $formName); } } } /** * Tansfrom the Dokuwiki {@link InputElement} into a Boostrap layout * @param Form $form - the form * @param int $elementPosition - the position of the element (that's how works {@link Form} * @param string $formName - the form name to create unique id (as the profile page has 2 forms) * @return int - the new position that should be used in a loop (the remove, add action reset the whole array indexes) */ public static function toBootStrapInputElementAndGetNewLoopingPosition(Form $form, int $elementPosition, string $formName): int { $inputElement = $form->getElementAt($elementPosition); if (!($inputElement instanceof InputElement)) { LogUtility::internalError("The element should be an input element"); return $elementPosition; } $inputType = $inputElement->getType(); $inputName = $inputElement->attr("name"); $labelObject = $inputElement->getLabel(); $label = ""; if ($labelObject !== null) { $label = $labelObject->val(); } $inputId = $inputElement->attr("id"); if (empty($inputId)) { $inputId = "user__$formName-input-$elementPosition"; $inputElement->id($inputId); } $placeholder = $inputElement->attr("placeholder"); if (empty($placeholder) && !empty($label)) { $inputElement->attr("placeholder", $label); } $newInputField = new InputElement($inputType, $inputName); foreach ($inputElement->attrs() as $keyAttr => $valueAttr) { $newInputField->attr($keyAttr, $valueAttr); } $newInputField->addClass("form-control"); $form->replaceElement($newInputField, $elementPosition); $form->addHTML('