Skip to content

Commit

Permalink
Add textatea tag.
Browse files Browse the repository at this point in the history
  • Loading branch information
ABGEO committed Jul 29, 2019
1 parent 6179169 commit 9557cc3
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 3 deletions.
24 changes: 21 additions & 3 deletions examples/example.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,23 @@
->add2Content(Element::createBreak())
->add2Content(Element::createBreak())
->add2Content(Element::createLine())
->add2Content(Element::createArticle('<p>Hello</p>', ['class1'], 'id'))
->add2Content(
Element::createArticle(
Element::createHeading('I\'m Article'), ['class1'], 'article'
)
)
->add2Content(Element::createBold('I\'m Bold text', [], 'bold'))
->add2Content(
Element::createBlockquote(
'I\'m Quote',
'http://www.worldwildlife.org/who/index.html', [], 'quote'
)
)
->add2Content(Element::createDiv('<p>I\'m Paragraph in Div</p>', [], '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))
Expand Down Expand Up @@ -126,7 +134,17 @@
], 'car'
)
)
->add2Content(Element::createFooter('<p>I\'m Paragraph in Footer</p>'));
->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)
Expand Down
47 changes: 47 additions & 0 deletions src/HTMLGenerator/Element.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<textarea{name_area}{placeholder_area}" .
"{classes_area}{id_area}>{content}</textarea>\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.
*
Expand Down

0 comments on commit 9557cc3

Please sign in to comment.