diff --git a/docs/2.0/field-options.md b/docs/2.0/field-options.md index 3ff3e4be..5fcad29d 100644 --- a/docs/2.0/field-options.md +++ b/docs/2.0/field-options.md @@ -43,7 +43,7 @@ To customize the label, you can use the `name` property to pick a different labe field :is_available, as: :boolean, name: 'Availability' ``` -Field naming convention override +Field naming convention override ## Showing / Hiding fields on different views @@ -155,7 +155,7 @@ end This example snippet will make the `:is_writer` field generate emojis instead of 1/0 values. -Fields formatter +Fields formatter ### Formatting with Rails helpers @@ -197,7 +197,7 @@ Add it to any field to make that column sortable in the view. field :name, as: :text, sortable: true ``` -Sortable fields +Sortable fields ## Custom sortable block @@ -255,7 +255,7 @@ Some fields support the `placeholder` option, which will be passed to the inputs field :name, as: :text, placeholder: 'John Doe' ``` -Placeholder option +Placeholder option ## Required @@ -265,7 +265,7 @@ When you want to mark a field as mandatory, you may use the `required` option to field :name, as: :text, required: true ``` -Required option +Required option :::warning This option is only a cosmetic one. It will not add the validation logic to your model. You must add that yourself (`validates :name, presence: true`). @@ -291,7 +291,7 @@ When you need to prevent the user from editing a field, the `readonly` option wi field :name, as: :text, readonly: true ``` -Readonly option +Readonly option ### Readonly as a block @@ -312,7 +312,7 @@ When you need to prevent the user from editing a field, the `disabled` option wi field :name, as: :text, disabled: true ``` -Disabled option +Disabled option ## Default Value @@ -339,7 +339,7 @@ field :custom_css, as: :code, theme: 'dracula', language: 'css', help: "This ena field :password, as: :password, help: 'You may verify the password strength here.' ``` -Help text +Help text :::info Since version `2.19`, the `default` block is being evaluated in the [`ResourceViewRecordHost`](./evaluation-hosts#resourceviewrecordhost). diff --git a/docs/3.0/field-options.md b/docs/3.0/field-options.md index 5d991f7d..a0089a10 100644 --- a/docs/3.0/field-options.md +++ b/docs/3.0/field-options.md @@ -9,10 +9,10 @@ feedbackId: 834 To customize the label, you can use the `name` property to pick a different label. ```ruby -field :is_available, as: :boolean, name: 'Availability' +field :is_available, as: :boolean, name: "Availability" ``` -Field naming convention override +Field naming convention override ## Showing / Hiding fields on different views @@ -83,7 +83,7 @@ end This example snippet will make the `:is_writer` field generate emojis instead of 1/0 values. -Fields formatter +Fields formatter ## Formatting with Rails helpers @@ -103,7 +103,7 @@ Add it to any field to make that column sortable in the view. field :name, as: :text, sortable: true ``` -Sortable fields +Sortable fields ## Custom sortable block @@ -161,29 +161,23 @@ Some fields support the `placeholder` option, which will be passed to the inputs field :name, as: :text, placeholder: 'John Doe' ``` -Placeholder option +Placeholder option ## Required +To indicate that a field is mandatory, you can utilize the `required` option, which adds an asterisk to the field as a visual cue. + +Avo automatically examines each field to determine if the associated attribute requires a mandatory presence. If it does, Avo appends the asterisk to signify its mandatory status. It's important to note that this option is purely cosmetic and does not incorporate any validation logic into your model. You will need to manually include the validation logic yourself, such as (`validates :name, presence: true`). -When you want to mark a field as mandatory, you may use the `required` option to add an asterisk to that field, indicating that it's mandatory. ```ruby field :name, as: :text, required: true ``` -Required option - -:::warning -For Avo versions 2.13 and lower, this option is only a cosmetic one. It will not add the validation logic to your model. You must add that yourself (`validates :name, presence: true`). -::: - -:::info -For Avo version 2.14 and higher Avo will automatically detect your validation rules and mark the field as required by default. -::: +Required option -You may use a block as well. It will be executed in the `ViewRecordHost` and you will have access to the `view`, `record`, `params`, `context`, `view_context`, and `current_user`. +You may use a block as well. It will be executed in the `Avo::ExecutionContext` and you will have access to the `view`, `record`, `params`, `context`, `view_context`, and `current_user`. ```ruby field :name, as: :text, required: -> { view == :new } # make the field required only on the new view and not on edit @@ -198,14 +192,14 @@ When you need to prevent the user from editing a field, the `disabled` option wi field :name, as: :text, disabled: true ``` -Disabled option +Disabled option ### Disabled as a block -You may use a block as well. It will be executed in the `ViewRecordHost` and you will have access to the `view`, `record`, `params`, `context`, `view_context`, and `current_user`. +You may use a block as well. It will be executed in the `Avo::ExecutionContext` and you will have access to the `view`, `record`, `params`, `context`, `view_context`, and `current_user`. ```ruby field :id, as: :number, disabled: -> { view == :edit } # make the field disabled only on the new edit view @@ -220,7 +214,7 @@ When you need to prevent the user from editing a field, the `readonly` option wi field :name, as: :text, readonly: true ``` -Readonly option +Readonly option ## Default Value @@ -247,11 +241,7 @@ field :custom_css, as: :code, theme: 'dracula', language: 'css', help: "This ena field :password, as: :password, help: 'You may verify the password strength here.' ``` -Help text - -:::info -Since version `2.19`, the `default` block is being evaluated in the [`ResourceViewRecordHost`](./evaluation-hosts#resourceviewrecordhost). -::: +Help text ## Nullable @@ -298,7 +288,7 @@ Related: It's customary on tables to align numbers to the right. You can do that using the `html` option. ```ruby{2} -class ProjectResource < Avo::BaseResource +class Avo::Resources::Project < Avo::BaseResource field :users_required, as: :number, html: {index: {wrapper: {classes: "text-right"}}} end ``` diff --git a/docs/public/assets/img/fields-reference/fields-formatter.jpg b/docs/public/assets/img/fields-reference/fields-formatter.jpg deleted file mode 100644 index 599bc08b..00000000 Binary files a/docs/public/assets/img/fields-reference/fields-formatter.jpg and /dev/null differ diff --git a/docs/public/assets/img/fields-reference/fields-formatter.png b/docs/public/assets/img/fields-reference/fields-formatter.png new file mode 100644 index 00000000..12a0b41f Binary files /dev/null and b/docs/public/assets/img/fields-reference/fields-formatter.png differ diff --git a/docs/public/assets/img/fields-reference/help-text.jpg b/docs/public/assets/img/fields-reference/help-text.jpg deleted file mode 100644 index 7df4c5f1..00000000 Binary files a/docs/public/assets/img/fields-reference/help-text.jpg and /dev/null differ diff --git a/docs/public/assets/img/fields-reference/help-text.png b/docs/public/assets/img/fields-reference/help-text.png new file mode 100644 index 00000000..43cd8b0a Binary files /dev/null and b/docs/public/assets/img/fields-reference/help-text.png differ diff --git a/docs/public/assets/img/fields-reference/naming-convention-override.jpg b/docs/public/assets/img/fields-reference/naming-convention-override.jpg deleted file mode 100644 index 2c2fe070..00000000 Binary files a/docs/public/assets/img/fields-reference/naming-convention-override.jpg and /dev/null differ diff --git a/docs/public/assets/img/fields-reference/naming-convention-override.png b/docs/public/assets/img/fields-reference/naming-convention-override.png new file mode 100644 index 00000000..6091a6e1 Binary files /dev/null and b/docs/public/assets/img/fields-reference/naming-convention-override.png differ diff --git a/docs/public/assets/img/fields-reference/placeholder.jpg b/docs/public/assets/img/fields-reference/placeholder.jpg deleted file mode 100644 index 7f132068..00000000 Binary files a/docs/public/assets/img/fields-reference/placeholder.jpg and /dev/null differ diff --git a/docs/public/assets/img/fields-reference/placeholder.png b/docs/public/assets/img/fields-reference/placeholder.png new file mode 100644 index 00000000..dea83c6a Binary files /dev/null and b/docs/public/assets/img/fields-reference/placeholder.png differ diff --git a/docs/public/assets/img/fields-reference/readonly.jpg b/docs/public/assets/img/fields-reference/readonly.jpg deleted file mode 100644 index 2092e360..00000000 Binary files a/docs/public/assets/img/fields-reference/readonly.jpg and /dev/null differ diff --git a/docs/public/assets/img/fields-reference/readonly.png b/docs/public/assets/img/fields-reference/readonly.png new file mode 100644 index 00000000..5e427e18 Binary files /dev/null and b/docs/public/assets/img/fields-reference/readonly.png differ diff --git a/docs/public/assets/img/fields-reference/required.jpg b/docs/public/assets/img/fields-reference/required.jpg deleted file mode 100644 index 9bae0b5d..00000000 Binary files a/docs/public/assets/img/fields-reference/required.jpg and /dev/null differ diff --git a/docs/public/assets/img/fields-reference/required.png b/docs/public/assets/img/fields-reference/required.png new file mode 100644 index 00000000..8e917d32 Binary files /dev/null and b/docs/public/assets/img/fields-reference/required.png differ diff --git a/docs/public/assets/img/fields-reference/sortable-fields.jpg b/docs/public/assets/img/fields-reference/sortable-fields.jpg deleted file mode 100644 index 27c843b7..00000000 Binary files a/docs/public/assets/img/fields-reference/sortable-fields.jpg and /dev/null differ diff --git a/docs/public/assets/img/fields-reference/sortable-fields.png b/docs/public/assets/img/fields-reference/sortable-fields.png new file mode 100644 index 00000000..c2018a3d Binary files /dev/null and b/docs/public/assets/img/fields-reference/sortable-fields.png differ