PHP code example of ui-awesome / form-model

1. Go to this page and download the library: Download ui-awesome/form-model library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ui-awesome / form-model example snippets




declare(strict_types=1);

namespace App\FormModel;

use UIAwesome\FormModel\BaseFormModel;
use UIAwesome\FormModel\Attribute\{FieldConfig, Hint, Label, Placeholder};

final class SignInForm extends BaseFormModel
{
    #[Hint('Use your account email address.')]
    #[Label('Email address')]
    #[Placeholder('[email protected]')]
    #[FieldConfig(['class' => ['w-full rounded-md border border-slate-300 px-3 py-2']])]
    public string $email = '';

    public string $password = '';

    public function getHints(): array
    {
        return [
            'password' => 'Use at least 8 characters.',
        ];
    }

    public function getLabels(): array
    {
        return [
            'password' => 'Password',
        ];
    }

    public function getPlaceholders(): array
    {
        return [
            'password' => 'Enter your password',
        ];
    }

    public function getRules(): array
    {
        return [
            'email' => ['

$hint = $form->getHint('profile.address.city');
$label = $form->getLabel('profile.address.city');
$placeholder = $form->getPlaceholder('profile.address.city');
$rules = $form->getRule('profile.address.city');

$emailHint = $form->getHint('email');
$emailLabel = $form->getLabel('email');
$emailPlaceholder = $form->getPlaceholder('email');
$emailFieldConfig = $form->getFieldConfig('email');

$form->setErrors(
    [
        'email' => ['Email is ],
);

$firstErrors = $form->getFirstErrors();
/*
[
    'email' => 'Email is