fieldcomponent_class
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| fieldcomponent_class [2021/10/08 21:10] – created sahl | fieldcomponent_class [2022/11/30 13:22] (current) – [Adding the component to the form] sahl | ||
|---|---|---|---|
| Line 59: | Line 59: | ||
| // $componentfield can now be added to a form | // $componentfield can now be added to a form | ||
| </ | </ | ||
| + | |||
| + | For convenience the form also have an addComponent-function that does exactly the same as above in one line: | ||
| + | |||
| + | <code php> | ||
| + | $textcomponent = new TextComponent(); | ||
| + | $form-> | ||
| + | </ | ||
| + | |||
| + | ===== Backend field validation ===== | ||
| + | |||
| + | It is also possible to perform backend field validation inside the component. The FieldComponent class has a '' | ||
| + | |||
| + | So backend validation for the component above could look like: | ||
| + | |||
| + | <code php> | ||
| + | function parse($value) : bool { | ||
| + | if ($value == ' | ||
| + | $this-> | ||
| + | return false; | ||
| + | } | ||
| + | $this-> | ||
| + | return true; | ||
| + | } | ||
| + | </ | ||
| + | |||
fieldcomponent_class.1633727426.txt.gz · Last modified: 2021/10/08 21:10 by sahl