Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
examples:builder:singe_attachment [2020/09/15 09:55] orville [Step 4: Upload media/files] |
examples:builder:singe_attachment [2021/12/09 10:56] (current) pdsci-admin |
||
|---|---|---|---|
| Line 2: | Line 2: | ||
| ====== Single media/file attachment: attachOne ====== | ====== Single media/file attachment: attachOne ====== | ||
| - | With the // | + | With the // |
| <WRAP tip> | <WRAP tip> | ||
| **Todo Cheat Sheet**\\ | **Todo Cheat Sheet**\\ | ||
| - | | + | * Add code to model: public $attachOne = ['yourFieldName' => [' |
| - | | + | * Add new //file upload// widget to the backend |
| - | * Add new //file upload// widget to form with 'yourField' as field | + | * Set at least allowed file extensions, width and height of image (if image files) |
| - | * Set allowed file extensions, width and height of image (if image files) | + | |
| </ | </ | ||
| Line 22: | Line 21: | ||
| Prerequisites are\\ | Prerequisites are\\ | ||
| * an installed [[https:// | * an installed [[https:// | ||
| - | * any source code editor or e.g. the [[https:// | + | * any source code editor or e.g. the [[https:// |
| * a database table for records to attach the media to | * a database table for records to attach the media to | ||
| * a form (at least in backend) to display the media | * a form (at least in backend) to display the media | ||
| Line 37: | Line 36: | ||
| The base model requires to know the type of desired relation as well as the name of the relation. This name can be seen like a field name of a database-table.\\ | The base model requires to know the type of desired relation as well as the name of the relation. This name can be seen like a field name of a database-table.\\ | ||
| - | The base model is located in the plugin directory, subdirectory //models// using the singular of the related db-table name. In our library | + | The base model is located in the plugin directory, subdirectory //models// using the singular of the related db-table name. In our example |
| / | / | ||
| Line 45: | Line 44: | ||
| <WRAP clear /> | <WRAP clear /> | ||
| \\ | \\ | ||
| - | These are the lines of code to add (comments are not necessary, | + | These are the lines of code to add for the library example to add images |
| <sxh php> | <sxh php> | ||
| // add a relation for a SINGLE image, field name is ' | // add a relation for a SINGLE image, field name is ' | ||
| Line 56: | Line 55: | ||
| ===== Step 2: Prepare the form ===== | ===== Step 2: Prepare the form ===== | ||
| - | Next step is to complete the form with an additional field to upload and display media and/or files:\\ | + | Next step is to complete the form with an additional field - the **File upload** widget |
| {{: | {{: | ||
| Line 65: | Line 64: | ||
| Finally, in the backend form view of the plugin, a file can be uploaded by clicking on the //file upload symbol// - the area below the 'Cover Image' title in the example:\\ | Finally, in the backend form view of the plugin, a file can be uploaded by clicking on the //file upload symbol// - the area below the 'Cover Image' title in the example:\\ | ||
| {{: | {{: | ||
| + | <WRAP clear /> | ||
| \\ | \\ | ||
| + | Now the form is ready to attach images and/or files to each record.\\ | ||
| + | ---- | ||
| \\ | \\ | ||
| - | + | Back to [[: | |
| - | ---- | + | |