Skip to content

Instantly share code, notes, and snippets.

@estefanionsantos
Created April 10, 2022 16:51
Show Gist options
  • Save estefanionsantos/e4ccd995d0e738272d8a39fe6d876036 to your computer and use it in GitHub Desktop.
Save estefanionsantos/e4ccd995d0e738272d8a39fe6d876036 to your computer and use it in GitHub Desktop.
form element
<?php
use Rubricate\Element\CreateElement;
$name = new CreateElement('input');
$name->setAttribute('type', 'text');
$name->setAttribute('name', 'name');
$name->setAttribute('required');
$email = new CreateElement('input');
$email->setAttribute('type', 'email');
$email->setAttribute('name', 'email');
$email->setAttribute('required');
$submit = new CreateElement('input');
$submit->setAttribute('type', 'submit');
$submit->setAttribute('name', 'submit');
$submit->setAttribute('value', 'ok');
$form = new CreateElement('form');
$form->setAttribute('action', 'process.php');
$form->setAttribute('method', 'post');
$form->addChild($name);
$form->addChild($email);
$form->addChild($submit);
echo $form->getElement();
/*
<form action="process.php" method="post">
<input type="text" name="name" required />
<input type="email" name="email" required />
<input type="submit" name="submit" value="ok" />
</form>
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment