diff --git a/examples/example.php b/examples/example.php index 8dcc087..73cae9b 100644 --- a/examples/example.php +++ b/examples/example.php @@ -22,7 +22,11 @@ ->add2Content(Element::createBreak()) ->add2Content(Element::createBreak()) ->add2Content(Element::createLine()) - ->add2Content(Element::createArticle('

Hello

', ['class1'], 'id')) + ->add2Content( + Element::createArticle( + Element::createHeading('I\'m Article'), ['class1'], 'article' + ) + ) ->add2Content(Element::createBold('I\'m Bold text', [], 'bold')) ->add2Content( Element::createBlockquote( @@ -30,7 +34,11 @@ 'http://www.worldwildlife.org/who/index.html', [], 'quote' ) ) - ->add2Content(Element::createDiv('

I\'m Paragraph in Div

', [], 'div')) + ->add2Content( + Element::createDiv( + Element::createParagraph('I\'m Paragraph in Div'), [], 'div' + ) + ) ->add2Content(Element::createHeading('H1')) ->add2Content(Element::createHeading('H3', 3)) ->add2Content(Element::createHeading('H6', 6)) @@ -126,7 +134,17 @@ ], 'car' ) ) - ->add2Content(Element::createFooter('

I\'m Paragraph in Footer

')); + ->add2Content(Element::createBreak()) + ->add2Content( + Element::createTextarea( + 'textarea', 'Text about me', 'About me' + ) + ) + ->add2Content( + Element::createFooter( + Element::createParagraph('I\'m Paragraph in Footer') + ) + ); $document ->setLanguage(Document::LANG_GEORGIAN) diff --git a/src/HTMLGenerator/Element.php b/src/HTMLGenerator/Element.php index a343a13..7a70eff 100644 --- a/src/HTMLGenerator/Element.php +++ b/src/HTMLGenerator/Element.php @@ -1149,6 +1149,53 @@ public static function createTable( return $return; } + /** + * Create textarea tag. + * + * @param string|null $name Textarea name. + * @param string|null $value Textarea value. + * @param string|null $placeholder Textarea placeholder. + * @param array $classes HTML Classes. + * @param string|null $id Element ID. + * + * @return string + */ + public static function createTextarea( + string $name = null, + string $value = null, + string $placeholder = null, + array $classes = [], + string $id = null + ): string { + $template = "{content}\n\t"; + + $nameArea = null; + $valueArea = ''; + $placeholderArea = null; + + if (null !== $name) { + $nameArea = " name=\"{$name}\""; + } + if (null !== $value) { + $valueArea = $value; + } + if (null !== $placeholder) { + $placeholderArea = " placeholder=\"{$placeholder}\""; + } + + $return = self::_createBaseFromTemplate( + $template, $valueArea, $classes, $id + ); + + $return = str_replace('{name_area}', $nameArea, $return); + $return = str_replace( + '{placeholder_area}', $placeholderArea, $return + ); + + return $return; + } + /** * Clear HTML Content. *