Browse Source

Limit form tex tinput length due to databse limits

kudlav 6 months ago
parent
commit
696b8050b5

+ 1 - 0
app/AdminModule/presenters/forms/EditTemplateFormFactory.php

@@ -44,6 +44,7 @@ class EditTemplateFormFactory
 		$form->addText('name', 'Name')
 			->setDefaultValue($this->template->name)
 			->setRequired('form.template_empty_name')
+			->addRule(Form::MAX_LENGTH, 'form.template_long_name', 45)
 			->setAttribute('placeholder', 'Template name')
 			->setAttribute('class', 'form-control')
 		;

+ 1 - 0
app/AdminModule/presenters/forms/EditVideoFormFactory.php

@@ -49,6 +49,7 @@ class EditVideoFormFactory
 		$form->addText('title', 'video.name')
 			->setDefaultValue($this->video->name)
 			->setRequired('form.video_empty_name')
+			->addRule(Form::MAX_LENGTH, 'form.video_long_name', 200)
 			->setAttribute('placeholder', 'video.name_placeholder')
 			->setAttribute('class', 'form-control')
 		;

+ 2 - 0
app/lang/form/form.cs_CZ.neon

@@ -11,7 +11,9 @@
 'course_empty' : 'U štítků je nutné vyplnit alespoň první štítek.'
 'video_empty_name' : 'Název videa nemůže být prázdný!'
 'video_empty_visibility' : 'Viditelnost videa musí být zadána!'
+'video_long_name' : 'Název videa může být maximálně 200 znaků dlouhý!'
 'template_empty_name' : 'Název šablony nemůže být prázdný!'
+'template_long_name' : 'Název šablony může být maximálně 45 znaků dlouhý!'
 'url_empty' : 'URL nesmí být prázdné!'
 'save' : 'Uložit'
 'upload' : 'Nahrát'

+ 2 - 0
app/lang/form/form.en_GB.neon

@@ -11,7 +11,9 @@
 'course_empty' : 'You have to fill in at least first tag.'
 'video_empty_name' : 'Name of video cannot be empty!'
 'video_empty_visibility' : 'Visibility of video must be specified!'
+'video_long_name' : 'Name of video can be only 200 characters long!'
 'template_empty_name' : 'Name of template cannot be empty!'
+'template_long_name' : 'Name of template can be only 45 characters long!'
 'url_empty' : 'URL cannot be empty!'
 'save' : 'Save'
 'upload' : 'Upload'

BIN
database-src.mwb


+ 10 - 0
database-updates.sql

@@ -269,6 +269,16 @@ CREATE FUNCTION `database_version` () RETURNS varchar(5) CHARACTER SET 'utf8'
 RETURN "1.11";$$
 DELIMITER ;
 
+-- 1.11 => 1.12 --
+ALTER TABLE `prednasky`.`video`
+  CHANGE COLUMN `name` `name` VARCHAR(200) NOT NULL ;
+DROP function IF EXISTS `prednasky`.`database_version`;
+DELIMITER $$
+USE `prednasky`$$
+CREATE FUNCTION `database_version` () RETURNS varchar(5) CHARACTER SET 'utf8'
+RETURN "1.12";$$
+DELIMITER ;
+
 -- END HERE --
 SET SQL_MODE=@OLD_SQL_MODE;
 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;

+ 4 - 2
database.sql

@@ -1,6 +1,6 @@
 -- MySQL Script generated by MySQL Workbench
+-- Tue Feb  5 16:02:52 2019
+-- Model: Prednasky.com    Version: 1.12
 -- MySQL Workbench Forward Engineering
 
 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
@@ -56,7 +56,7 @@ DROP TABLE IF EXISTS `prednasky`.`video` ;
 
 CREATE TABLE IF NOT EXISTS `prednasky`.`video` (
   `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
-  `name` VARCHAR(100) NOT NULL,
+  `name` VARCHAR(200) NOT NULL,
   `created` TIMESTAMP NOT NULL,
   `state` INT UNSIGNED NOT NULL,
   `complete` TINYINT(1) NOT NULL,
@@ -373,7 +373,7 @@ DROP function IF EXISTS `prednasky`.`database_version`;
 DELIMITER $$
 USE `prednasky`$$
 CREATE FUNCTION `database_version` () RETURNS varchar(5) CHARACTER SET 'utf8'
-RETURN "1.11";$$
+RETURN "1.12";$$
 
 DELIMITER ;