-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Docs(web-twig): Introduce demo page for form validations
refs #DS-812
- Loading branch information
Showing
9 changed files
with
119 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
apps/web-twig-demo/src/Controller/ValidationsController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace App\Controller; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\Routing\Annotation\Route; | ||
|
||
class ValidationsController extends AbstractController | ||
{ | ||
#[Route('/validations')] | ||
public function index(): Response | ||
{ | ||
return $this->render('validations.html.twig'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{% extends 'layout/default.html.twig' %} | ||
|
||
{% block content %} | ||
|
||
<section class="docs-Section"> | ||
|
||
<Grid UNSAFE_className="mb-1200"> | ||
<GridSpan over="10" tablet="6" desktop="4"> | ||
<h2 class="docs-Heading">Real-World examples</h2> | ||
|
||
<form id="form1" method="get" novalidate> | ||
<Stack hasSpacing> | ||
{% set usernameInputProps = { "data-spirit-required-message": "Please choose a username" }%} | ||
<TextField isFluid name="username" id="username" label="Username" isRequired data-spirit-validate inputProps={ usernameInputProps } /> | ||
{% set zipcodeInputProps = { "data-spirit-pattern-message": "Invalid ZIP code", "data-spirit-pattern": "/d{5}|\d{3}[ ]?\d{2}/" }%} | ||
<TextField isFluid name="zipcode" id="zipcode" label="Zip code" placeholder="123" data-spirit-validate inputProps={ zipcodeInputProps } /> | ||
{% set ageInputProps = { "data-spirit-min-message": "You must be at least 14-years-old", }%} | ||
<TextField isFluid name="age" id="age" label="Your age (min. 14)" isRequired min="14" data-spirit-validate inputProps={ ageInputProps } /> | ||
{% set passwordInputProps = { | ||
"data-spirit-required-message": "Please choose a password", | ||
"data-spirit-pattern": "/^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9]).{8,}$/", | ||
"data-spirit-pattern-message": "Minimum 8 characters, at least one uppercase letter, one lowercase letter and one number" | ||
} %} | ||
<TextField isFluid name="password" id="password" type="password" label="Password" isRequired data-spirit-validate inputProps={ passwordInputProps } /> | ||
{% set retypepasswordInputProps = { | ||
"data-spirit-equals": "#password", | ||
"data-spirit-equals-message": "Passwords don't match", | ||
} %} | ||
<TextField isFluid name="retypepassword" id="retypepassword" type="password" label="Retype password" isRequired data-spirit-validate inputProps={ retypepasswordInputProps } /> | ||
{% set emailInputProps = { "data-spirit-required-message": "Please enter your email", } %} | ||
<TextField isFluid name="email" id="email" type="email" label="Email" isRequired data-spirit-validate inputProps={ emailInputProps } /> | ||
{% set phoneInputProps = { "data-spirit-pattern": "/^(?:\+\d{3}\s?)?(\d{3}\s?){3}$/", "data-spirit-pattern-message": "Invalid phone number", } %} | ||
<TextField isFluid name="phone" id="phone" type="tel" label="phone" isRequired placeholder="+420 733 333 333" data-spirit-validate inputProps={ phoneInputProps } /> | ||
<CheckboxField isFluid name="checkboxfield1" id="checkboxfield1" label="I accept the terms and conditions (required)" isRequired data-spirit-validate /> | ||
<div> | ||
<Button type="submit" color="primary" isBlock>Submit</Button> | ||
</div> | ||
</Stack> | ||
</form> | ||
</GridSpan> | ||
</Grid> | ||
</section> | ||
|
||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters