Remove the model, start working on Form class for building forms.
This commit is contained in:
parent
ad81fa935f
commit
3a6f92f78a
@ -20,7 +20,8 @@
|
||||
"cycle/orm": "^2.10",
|
||||
"cycle/annotated": "^4.3",
|
||||
"cycle/schema-builder": "^2.11",
|
||||
"cycle/entity-behavior": "^1.4"
|
||||
"cycle/entity-behavior": "^1.4",
|
||||
"formr/formr": "^1.5"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^11.1",
|
||||
|
50
app/composer.lock
generated
50
app/composer.lock
generated
@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "603e7a3826c49462a29dfb5e74fc1bdb",
|
||||
"content-hash": "db2cdf69d3b4afb612a86a9b2e48afd7",
|
||||
"packages": [
|
||||
{
|
||||
"name": "brick/math",
|
||||
@ -1177,6 +1177,54 @@
|
||||
},
|
||||
"time": "2020-11-24T22:02:12+00:00"
|
||||
},
|
||||
{
|
||||
"name": "formr/formr",
|
||||
"version": "v1.5.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/formr/formr.git",
|
||||
"reference": "6ee7d46cc8f353f44b69cec5ab0d0d3568e1a836"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/formr/formr/zipball/6ee7d46cc8f353f44b69cec5ab0d0d3568e1a836",
|
||||
"reference": "6ee7d46cc8f353f44b69cec5ab0d0d3568e1a836",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-mbstring": "*",
|
||||
"php": ">=8.1"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"files": [
|
||||
"class.formr.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"GPL-2.0-only"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Tim Gavin",
|
||||
"homepage": "https://formr.github.io",
|
||||
"role": "Original Author"
|
||||
}
|
||||
],
|
||||
"description": "Formr is a PHP library which helps you build and validate forms quickly, painlessly, and without all the messy overhead.",
|
||||
"support": {
|
||||
"issues": "https://github.com/formr/formr/issues",
|
||||
"source": "https://github.com/formr/formr/tree/v1.5.4"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://github.com/timgavin",
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2025-07-15T15:34:42+00:00"
|
||||
},
|
||||
{
|
||||
"name": "graham-campbell/result-type",
|
||||
"version": "v1.1.3",
|
||||
|
@ -1 +0,0 @@
|
||||
import { series } from "gulp";
|
@ -1 +0,0 @@
|
||||
// nothing here yet
|
@ -1,3 +0,0 @@
|
||||
export function checkPasswords(form) {
|
||||
|
||||
}
|
2172
app/package-lock.json
generated
2172
app/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,20 +0,0 @@
|
||||
{
|
||||
"name": "slovocast",
|
||||
"version": "1.0.0",
|
||||
"description": "The Slovocast Podcast Platform Frontend",
|
||||
"main": "js/index.js",
|
||||
"directories": {
|
||||
"test": "tests"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "Dave Smith-Hayes",
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"gulp": "^5.0.0",
|
||||
"gulp-cli": "^3.0.0",
|
||||
"gulp-sass": "^5.1.0",
|
||||
"sass": "^1.81.0"
|
||||
}
|
||||
}
|
@ -1,62 +0,0 @@
|
||||
body {
|
||||
background-color: #eee;
|
||||
}
|
||||
|
||||
.container {
|
||||
box-sizing: border-box;
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
header {
|
||||
float: left;
|
||||
padding: 0.25em 1em;
|
||||
|
||||
h1 {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
}
|
||||
|
||||
nav {
|
||||
float: right;
|
||||
padding: 0.25em 1em;
|
||||
ul {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
|
||||
li {
|
||||
display: inline;
|
||||
}
|
||||
li:last-child {
|
||||
margin-left: 1em;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
main {
|
||||
clear: both;
|
||||
background-color: #fff;
|
||||
border: 1px solid #ccc;
|
||||
padding: 1em;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.flash {
|
||||
padding: 0.5em;
|
||||
box-sizing: border-box;
|
||||
margin-bottom: 1em;
|
||||
color: #fff;
|
||||
}
|
||||
.error {
|
||||
border: 1px solid #140505;
|
||||
border-radius: 5px;
|
||||
background-color: #C32727;
|
||||
}
|
||||
|
||||
footer {
|
||||
text-align: right;
|
||||
padding: 0.25em 1em;
|
||||
}
|
15
app/src/Service/Api/FormServiceInterface.php
Normal file
15
app/src/Service/Api/FormServiceInterface.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Slovocast\Service\Api;
|
||||
|
||||
/**
|
||||
* The Form Service allows one to create a virtual form, send it to the view,
|
||||
* and then handle the subsequent request. Any active form in a session will
|
||||
* can be parsed and handled in the next request.
|
||||
*/
|
||||
interface FormServiceInterface
|
||||
{
|
||||
public function build($entity);
|
||||
public function validate($data);
|
||||
public function handle($request);
|
||||
}
|
48
app/src/Service/Forms/Form.php
Normal file
48
app/src/Service/Forms/Form.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace Slovocast\Service\Forms;
|
||||
|
||||
use DOMDocument;
|
||||
use DOMElement;
|
||||
|
||||
/**
|
||||
* The Form class is a virutal represenation of a Form.
|
||||
*/
|
||||
class Form
|
||||
{
|
||||
public readonly DOMDocument $form;
|
||||
|
||||
public function __construct(
|
||||
public readonly string $name,
|
||||
public readonly string $method,
|
||||
public readonly string $action
|
||||
) {
|
||||
}
|
||||
|
||||
public function output(): string
|
||||
{
|
||||
$doc = new DOMDocument();
|
||||
$doc->normalize();
|
||||
return $doc->saveHTML($this->form);
|
||||
}
|
||||
|
||||
protected function addElement(string $type, array $properties): DOMElement
|
||||
{
|
||||
$elem = new DOMElement($type);
|
||||
foreach ($properties as $attr => $value) {
|
||||
$elem->setAttribute($attr, $value);
|
||||
}
|
||||
|
||||
return $elem;
|
||||
}
|
||||
|
||||
public function addInput(string $name, array $properties = []): static
|
||||
{
|
||||
$input = $this->addElement('input', [
|
||||
'name' => $name,
|
||||
...$properties
|
||||
]);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
@ -8,6 +8,8 @@
|
||||
{% endblock %}
|
||||
<link rel="stylesheet" href="/static/main.css">
|
||||
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/kelpui@0/css/kelp.css">
|
||||
<script type="module" src="https://cdn.jsdelivr.net/npm/kelpui@0/js/kelp.js"></script>
|
||||
{% block head_js %}{% endblock %}
|
||||
</head>
|
||||
<body>
|
||||
@ -17,16 +19,16 @@
|
||||
{% block header %}{% endblock %}
|
||||
</header>
|
||||
|
||||
{% include 'layouts/components/navigation.twig' %}
|
||||
{% include 'components/navigation.twig' %}
|
||||
|
||||
<main>
|
||||
{% include 'layouts/components/flash.twig' %}
|
||||
{% include 'components/flash.twig' %}
|
||||
{% block content %}{% endblock %}
|
||||
</main>
|
||||
|
||||
<footer>
|
||||
{% block footer %}
|
||||
© 2024, Slovocast
|
||||
© 2025, Slovocast
|
||||
{% endblock %}
|
||||
</footer>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user