Skip to content

Commit

Permalink
Reword and update form helper example usage
Browse files Browse the repository at this point in the history
  • Loading branch information
ifox committed Jun 8, 2021
1 parent 33717de commit 908fb63
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
10 changes: 5 additions & 5 deletions docs/.sections/form-fields.md
Original file line number Diff line number Diff line change
Expand Up @@ -1070,7 +1070,7 @@ Schema::table('posts', function (Blueprint $table) {
...
});
```
### Conditional Fields
### Conditional fields

You can conditionally display fields based on the values of other fields in your form. For example, if you wanted to display a video embed text field only if the type of article, a radio field, is "video" you'd do something like the following:

Expand All @@ -1092,7 +1092,7 @@ You can conditionally display fields based on the values of other fields in your
]
])

@component('twill::partials.form.utils._connected_fields', [
@formConnectedFields([
'fieldName' => 'type',
'fieldValues' => 'video',
'renderForBlocks' => true/false # (depending on regular form vs block form)
Expand All @@ -1101,7 +1101,7 @@ You can conditionally display fields based on the values of other fields in your
'name' => 'video_embed',
'label' => 'Video embed'
])
@endcomponent
@endformConnectedFields
```
Here's an example based on a checkbox field where the value is either true or false:

Expand All @@ -1111,7 +1111,7 @@ Here's an example based on a checkbox field where the value is either true or fa
'label' => 'Vertical Story'
])

@component('twill::partials.form.utils._connected_fields', [
@formConnectedFields([
'fieldName' => 'vertical_article',
'fieldValues' => true,
'renderForBlocks' => true/false # (depending on regular form vs block form)
Expand All @@ -1120,5 +1120,5 @@ Here's an example based on a checkbox field where the value is either true or fa
'name' => 'vertical_image',
'label' => 'Vertical Image',
])
@endcomponent
@endformConnectedFields
```
7 changes: 5 additions & 2 deletions docs/.sections/media-library.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ $model->hasImage($roleName[, $cropName])
```

### File library
The file library is much simpler but also works with S3 and local storage. To associate files to your model, use the `HasFiles` and `HandleFiles` traits, the `$filesParams` configuration and the `files` form partial.
The file library is much simpler but also works with S3 and local storage. To associate files to your model, use the `HasFiles` and `HandleFiles` traits, the `$filesParams` configuration and the `files` form field.

When it comes to using those data model files in the frontend site, there are a few methods on the `HasFiles` trait that will help you to retrieve direct URLs:

Expand All @@ -150,7 +150,10 @@ $model->filesList($roleName[, $locale])
$model->fileObject($roleName)
```

What to do with videos? Typically files like .mp4 videos are uploaded under the "Files" tab in the media library instead of under "Images".
::: tip INFO
The file library can be used to upload files of any type and to attach those files to records using the `file` form field.
For example, you could store video files and render them on your frontend, with a CDN on top of it. We recommand Youtube and Vimeo for regular video embeds, but for muted, decorative, autoplaying videos, .mp4 files in the file library can be a great solution.
:::

### Imgix and S3 direct uploads

Expand Down

0 comments on commit 908fb63

Please sign in to comment.