Overview
Comment:Allow d/m/Y date format
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | dev
Files: files | file ages | folders
SHA1: e4d78127c5144e552a6751929cd3b7a0a524919e
User & Date: bohwaz on 2020-09-29 17:24:23
Other Links: branch diff | manifest | tags
Context
2020-09-29
17:25
Link users to transactions check-in: 1ba9497799 user: bohwaz tags: dev
17:24
Allow d/m/Y date format check-in: e4d78127c5 user: bohwaz tags: dev
16:53
Input lists: implement multiple choice check-in: 12cfcd4abf user: bohwaz tags: dev
Changes

Modified src/include/lib/Garradin/Entity.php from [8182e740f9] to [d13211bc8d].

11
12
13
14
15
16
17




18
19
20
21
22
23
24
25
26
27
28










29
30
31
32
33
34
35
36

	/**
	 * Valider les champs avant enregistrement
	 * @throws ValidationException Si une erreur de validation survient
	 */
	public function importForm(array $source = null)
	{




		$form = new Form;

		if (!$form->validate($this->_form_rules, $source))
		{
			$messages = $form->getErrorMessages();

			throw new ValidationException(implode("\n", $messages));
		}

		return $this->import($source);
	}











	protected function assert(bool $test, string $message = null): void
	{
		if (null !== $message && !$test) {
			throw new ValidationException($message);
		}
	}
}







>
>
>
>











>
>
>
>
>
>
>
>
>
>








11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50

	/**
	 * Valider les champs avant enregistrement
	 * @throws ValidationException Si une erreur de validation survient
	 */
	public function importForm(array $source = null)
	{
		if (null === $source) {
			$source = $_POST;
		}

		$form = new Form;

		if (!$form->validate($this->_form_rules, $source))
		{
			$messages = $form->getErrorMessages();

			throw new ValidationException(implode("\n", $messages));
		}

		return $this->import($source);
	}

	protected function filterUserValue(string $type, $value)
	{
		if ($type == 'date') {
			return \DateTime::createFromFormat('d/m/Y', $value);
		}
		else {
			return parent::filterUserValue($type, $value);
		}
	}

	protected function assert(bool $test, string $message = null): void
	{
		if (null !== $message && !$test) {
			throw new ValidationException($message);
		}
	}
}