### Install Freeform via Composer (CLI)
Source: https://github.com/solspace/documentation/blob/main/craft-freeform/setup/installing-updating.mdx
Install Freeform using Composer in your Craft project's CLI. This method allows for installing the latest version or a specific version. After requiring the package, you can install the plugin via the CLI, specifying the desired edition (pro, lite, or express).
```nix
cd /path/to/project
composer require solspace/craft-freeform -w
./craft plugin/install freeform pro
```
```nix
cd /path/to/project
composer require solspace/craft-freeform:5.10.15 -w
./craft plugin/install freeform pro
```
```nix
cd /path/to/project
composer require solspace/craft-freeform -w
./craft plugin/install freeform
```
--------------------------------
### Install AI Assistant via Composer CLI
Source: https://github.com/solspace/documentation/blob/main/craft-ai-assistant/setup/installing-updating.mdx
Installs the latest version of AI Assistant using Composer. Requires a CLI application and Composer to be installed.
```nix
cd /path/to/project
composer require solspace/craft-aiassistant -w
```
--------------------------------
### Render a Form using Twig
Source: https://github.com/solspace/documentation/blob/main/craft-freeform/templates/queries/form.mdx
Demonstrates how to initialize and render a form using the freeform.form query. The basic example renders the form directly, while the advanced example shows how to pass configuration objects for attributes, field styling, and global overrides.
```twig
{{ freeform.form("myFormHandle").render() }}
```
```twig
{{ freeform.form("myFormHandle", {
attributes: {
novalidate: true,
class: "my-form-class",
},
buttons: {
attributes: {
submit: { class: "form-field-button blue" },
back: { class: "form-field-button gray" },
},
},
fields: {
"@global": {
attributes: {
input: {
class: "form-field-input",
},
label: {
class: "form-field-label",
},
},
},
":required": {
attributes: {
label: { "+class": "form-field-required" },
},
},
":errors": {
attributes: {
input: { "+class": "form-field-is-invalid" },
},
},
"@dropdown": {
attributes: {
container: {
"data-select-container": true,
},
input: {
"+class": "form-field-select fullwidth",
},
},
},
"@checkboxes, @radios" : {
attributes: {
input: {
"+class": "form-field-options",
},
},
},
"myFieldHandle": {
value: entry.id,
},
},
}).render() }}
```
--------------------------------
### Install Calendar Plugin via CLI
Source: https://github.com/solspace/documentation/blob/main/craft-calendar/setup/installing-updating.mdx
Installs the Calendar plugin after it has been added via Composer. This command is run from the root of your Craft project.
```sh
php craft plugin/install calendar
```
--------------------------------
### Install Specific Version of AI Assistant via Composer CLI
Source: https://github.com/solspace/documentation/blob/main/craft-ai-assistant/setup/installing-updating.mdx
Installs a specific version of AI Assistant using Composer. Requires a CLI application and Composer to be installed.
```nix
composer require solspace/craft-aiassistant:1.0.6 -w
```
--------------------------------
### Install Project Dependencies
Source: https://github.com/solspace/documentation/blob/main/README.md
Installs all required project dependencies defined in the package.json file using the Yarn package manager.
```shell
yarn
```
--------------------------------
### Example: List All Calendars with Pagination
Source: https://github.com/solspace/documentation/blob/main/ee-calendar/templating/calendars.mdx
An example demonstrating how to list all available calendars or specific calendar information based on URL segments. It includes dynamic filtering using `segment_3`, setting a limit, enabling pagination, and displaying results or a 'no results' message.
```html
{exp:calendar:calendars
{if segment_3} calendar_short_name="{segment_3}"{/if}
limit="10"
paginate="both"
}
- {calendar:name}
{if calendar:no_results}
- No results found.
{/if}
{calendar:paginate}
- Page {calendar:current_page} of {calendar:total_pages} pages. {calendar:pagination_links}
{/calendar:paginate}
{/exp:calendar:calendars}
```
--------------------------------
### File Upload Drag & Drop SCSS Customization Example
Source: https://github.com/solspace/documentation/blob/main/craft-freeform/forms/fields.mdx
Provides an example of how to customize the File Upload Drag & Drop field's appearance using SCSS. This demonstrates overriding default styles for the input, preview zone, and remove button.
```css
.freeform-file-dnd__input {
background: blue;
&__preview-zone {
&__file-preview {
border: 3px solid grey;
&__thumbnail {
border: 1px solid black;
padding: 5px;
&__remove-button {
border-radius: 0;
}
}
}
}
}
```
--------------------------------
### Install Calendar Latest Version via CLI
Source: https://github.com/solspace/documentation/blob/main/craft-calendar/setup/installing-updating.mdx
Installs the latest version of the Calendar plugin using Composer. This command should be run from the root of your Craft project.
```sh
cd /path/to/project
composer require solspace/craft-calendar -w
```
--------------------------------
### Example Twig Heading for Predefined Assets
Source: https://github.com/solspace/documentation/blob/main/craft-freeform/forms/email-notifications.mdx
An example of a complete heading comment block in a Twig template file, including `presetAssets` to specify which assets should be attached to email notifications. This allows for dynamic attachment inclusion based on template configuration.
```twig
{# subject: New submission from your {{ form.name }} form #}
{# fromEmail: {{ craft.app.projectConfig.get('email.fromEmail') }} #}
{# fromName: {{ craft.app.projectConfig.get('email.fromName') }} #}
{# replyToEmail: {{ email }} #}
{# replyToName: {{ firstName }} {{ lastName }} #}
{# cc: ring@my-precio.us #}
{# bcc: #}
{# includeAttachments: true #}
{# presetAssets: 42,67 #}
{# templateName: My Template Name #}
{# description: A description of what this template does. #}
```
--------------------------------
### Install AI Assistant Plugin via CLI
Source: https://github.com/solspace/documentation/blob/main/craft-ai-assistant/setup/installing-updating.mdx
Installs the AI Assistant plugin after it has been added via Composer. Requires access to the Craft CMS console.
```nix
./craft plugin/install ai-assistant
```
--------------------------------
### Example Twig Heading for Template Wrapper
Source: https://github.com/solspace/documentation/blob/main/craft-freeform/forms/email-notifications.mdx
An example of a complete heading comment block in a Twig template file, including the `wrapperId` to specify a template wrapper. This demonstrates how to set various notification parameters directly in the template's metadata.
```twig
{# subject: New submission from your {{ form.name }} form #}
{# fromEmail: {{ craft.app.projectConfig.get('email.fromEmail') }} #}
{# fromName: {{ craft.app.projectConfig.get('email.fromName') }} #}
{# replyToEmail: {{ email }} #}
{# replyToName: {{ firstName }} {{ lastName }} #}
{# cc: ring@my-precio.us #}
{# bcc: #}
{# includeAttachments: true #}
{# presetAssets: 42,67 #}
{# wrapperId: 1 #}
{# templateName: My Template Name #}
{# description: A description of what this template does. #}
```
--------------------------------
### Example Success Template Structure
Source: https://github.com/solspace/documentation/blob/main/craft-freeform/configuration/settings.mdx
A basic example of a Twig template file used for displaying success messages after form submission. It includes placeholders for dynamic data like form ID and name.
```twig
```
--------------------------------
### File Upload Drag & Drop CSS Customization Example
Source: https://github.com/solspace/documentation/blob/main/craft-freeform/forms/fields.mdx
Illustrates how to customize the File Upload Drag & Drop field's appearance using regular CSS. This example shows how to apply styles directly and use '!important' to ensure overrides take effect.
```css
.freeform-file-dnd__input {
background: blue !important;
border: 1px solid red !important;
}
.freeform-file-dnd__placeholder {
font-size: 12px !important;
}
.freeform-file-dnd__preview-zone__file-preview__thumbnail {
border: 3px solid yellow !important;
}
.freeform-file-dnd__preview-zone__file-preview__thumbnail__remove-button {
border-radius: 0 !important;
}
```
--------------------------------
### Manage Dependencies via Composer
Source: https://github.com/solspace/documentation/blob/main/craft-freeform/setup/installing-updating.mdx
Configuration examples for updating the composer.json file to manage Freeform versions. Includes both caret-based versioning for automatic updates and explicit version locking.
```json
"require": {
"craftcms/cms": "^5.0.0",
"vlucas/phpdotenv": "^5.4.0",
"solspace/craft-freeform": "^5.0.0",
"solspace/craft-calendar": "^5.0.0"
}
```
```diff
"require": {
"craftcms/cms": "5.6.1",
"vlucas/phpdotenv": "5.4.0",
- "solspace/craft-freeform": "5.7.2",
+ "solspace/craft-freeform": "5.9.15",
"solspace/craft-calendar": "5.0.14"
}
```
--------------------------------
### DynamicSelect API Request Example
Source: https://github.com/solspace/documentation/blob/main/craft-freeform/developer/field-properties/dynamic-select.mdx
An example of the resulting HTTP GET request generated by the DynamicSelect property when parameters are mapped from the form fields.
```http
http://localhost:3000/api/foods?formId=123&defaultValue=sushi¤tValue=pizza&label=Choose+your+favorite+food
```
--------------------------------
### Importing UI Components and Utilities
Source: https://github.com/solspace/documentation/blob/main/craft-freeform/guides/guide/file-upload-custom-delete-dialog.mdx
Imports necessary components and utilities for building the documentation interface. Includes Tabs, TabItem for tabbed content, VerticalStepWrapper and StepMarkdown for structured steps, and Badge and Photo for visual elements.
```javascript
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import { VerticalStepWrapper, StepMarkdown } from '@site/src/components/docs';
import { Badge, Photo } from '@site/src/components/utils';
```
--------------------------------
### Show Only Events Starting on Weekdays
Source: https://github.com/solspace/documentation/blob/main/craft-calendar/templates/queries/week.mdx
This example demonstrates how to retrieve a Week object using the calendar.week query and then filter the events to display only those that start on a weekday. It utilizes a conditional within the loop.
```twig
{% set week = craft.calendar.week({
date: "today",
calendar: ["holidays", "sports"]
}) %}
{% for event in week.events if event.startDate.weekday %}
{{ event.title }}
{% endfor %}
```
--------------------------------
### Twig Formatting Template Integration
Source: https://github.com/solspace/documentation/blob/main/craft-freeform/guides/guide/range-slider-number.mdx
An example of how to integrate the Range field type within a Twig formatting template, specifically using the 'Basic Light' template as a starting point. This snippet shows the conditional rendering based on the field type and the inclusion of necessary HTML structure.
```twig
{# Shortened for Example #}
...