Uniform strange thing

Hi there, I have strange error with Uniform plugin.

Im trying create simple form. Made everything by instructions

contact.php controller

<?php

use Uniform\Form;

return function ($kirby) {
   $form = new Form([
      'email' => [
         'rules' => ['required', 'email'],
         'message' => 'Please provide a valid email',
      ],
      'subject' => [],
      'message' => [
         'rules' => ['required'],
         'message' => 'Please enter a message',
      ],
   ]);

   if ($kirby->request()->is('POST')) {
      $form->emailAction([
         'to' => 'some@mail.com',
         'from' => 'no-reply@mail.com',
      ]);
   }

   return compact('form');
};

contact.php template

<form class="col-lg-6 pt-5" action="<?php echo $page->url() ?>" method="POST">
				<div class="form-group">
		
					<input type="email" type="email" class="form-control <?php if ($form->error('email')): ?>is-invalid<?php endif; ?>" id="email" placeholder="Your Email" value="<?= $form->old('email'); ?>">
					<?php if ($form->error('email')): ?>
					    <div class="invalid-feedback"><?php echo implode($form->error('email')) ?></div>
					<?php endif; ?>
					<input type="text" class="form-control mt-4 <?php if ($form->error('subject')): ?>is-invalid<?php endif; ?>" id="subject" placeholder="Subject" value="<?php echo $form->old('subject'); ?>">
					<?php if ($form->error('subject')): ?>
					    <div class="invalid-feedback"><?php echo implode('<br>', $form->error('subject')) ?></div>
					<?php endif; ?>
					<textarea class="form-control mt-4 <?php if ($form->error('message')): ?>is-invalid<?php endif; ?>" id="message" rows="3" placeholder="Your message here"><?php echo $form->old('message'); ?></textarea>
					<?php if ($form->error('message')): ?>
					    <div class="invalid-feedback"><?php echo implode('<br>', $form->error('message')) ?></div>
					<?php endif; ?>
				</div>
			    <?php echo csrf_field(); ?>
				<?php echo honeypot_field(); ?>
				<input type="submit" class="btn btn-outline-primary btn-lg" value="Submit">
			</form>
			<?php if ($form->success()): ?>
			<div class="alert alert-success" role="alert">Success!</div>
			<?php endif; ?>	

And when im trying to send message, I have errors. for every field that is required. https://take.ms/20jyd

I think that this is because of multi lang site, but after disabling other languages the problem is still preset. I’m read all docs, but didn’t found any ideas, why it is not works…

plugin is installed in /plugins/uniform/

controller is back me errors, so it is works… but I didn’t understand why data that im sending in form isn’t visible for plugin

Your form is missing the name attributes.

1 Like

Lot of thanks!!! :wink: