Commit Graph

144 Commits

Author SHA1 Message Date
Samuell 348040a4e4 Add permission support for fields, columns and filter scopes (#4520)
Credit to @Samuell1. Fixes #1837.
2019-10-09 16:41:53 -06:00
Luke Towers e246427463 Provide system.assets.beforeAddAsset event to modify asset attributes
Fixes octobercms/october#4611 (when combined with a PR to https://github.com/heathdutton/cloudflare)
Related: octobercms/october#4092, octobercms/october#3841, octobercms/october#3839
2019-10-09 11:51:06 -06:00
Dan Harrin 9521dd795c Minor Formatting Corrections in Usage Comments (#4541)
Credit to @DanHarrin
2019-08-15 09:14:54 -06:00
Ben Thomson 610e0c383c
Set validation attributes after context check.
This prevent fields with multiple contexts from overwriting the label name of another context in the validation messages.

Fixes https://github.com/rainlab/user-plugin/issues/371.
2019-07-26 00:27:45 +08:00
Ben Thomson a59d3b83eb Code quality clean up (#4449)
Credit to @bennothommo
2019-07-18 08:50:37 -06:00
SeriousKen a9e198c8b4 Add check to make sure event result is an array in Form widget (#4331)
Wildcard listeners will add null responses to the event result array and causes an error when they are merged into the result. This PR adds a check to see if each event result is an array before adding it to the result array.

Credit to @SeriousKen. Fixes https://github.com/OFFLINE-GmbH/oc-clockwork-plugin/issues/1
2019-05-20 13:32:29 +08:00
Rachasak Ragkamnerd 70cd444f8a Added support for 'cache' attribute to addJs() to disable CF RocketLoader (#4092)
Credit to @itpcc 

Due to CloudFlare Rocket Loader, CF will automatically try to optimize page loading speed by changing script type attribute. This breaks the script execution order and makes the user unable to upload the file(s) in the backend using "FileUpload" widget.

However, [CloudFlare allows adding "data-cfasync"](https://support.cloudflare.com/hc/en-us/articles/200169436-How-can-I-have-Rocket-Loader-ignore-specific-JavaScripts-) to prevent this. And it was used in the [commit #3841](https://github.com/octobercms/october/pull/3841/files).
2019-04-16 20:27:13 -06:00
Tomy Smith 40bc6e0d67 Ignore disabled FormWidgets in getSaveData() (#4116)
Fixes #3983. Credit to @tmus.
2019-03-19 16:45:32 -06:00
Ben Thomson 13a7cc915d Use Form getSaveData method when saving form widgets within repeaters (#4160)
Credit to @bennothommo
2019-03-15 22:39:34 -06:00
Antonie Hogewoning 16ca521cd0 Fix setting default values for repeater in update context (#4098)
Credit to @CptMeatball
2019-01-31 13:50:21 -06:00
Anže Časar 74484b1ec2 Fix default value translation (#4062)
Credit to @acasar
2019-01-15 13:38:22 -06:00
Luke Towers 1c0fd1b419 Yet another change to perfect the getParentForm() method 2019-01-10 18:59:29 -06:00
Luke Towers 1b3263d4c7 Pass the containing Form widget to the FormFields that it generates.
This enables complex FormWidgets that need to know what Form widget they belong to to access that information with $this->formField->form; This also enables a fix for: https://github.com/rainlab/location-plugin/issues/48
2019-01-10 10:22:59 -06:00
Farrow a1fb23a984 Adds i18n support for the form field default property (#3546)
Credit to @Farrow. Previously when creating a backend form with RainLab.Builder if you filled in the "Default" property using the i18n (to get, for example, acme.plugin::lang.field.default) then that string would be output exactly on the form (i.e. <input value="acme.plugin::lang.field.default"...>) instead of being replaced with the actual value of that key from the lang file.
2018-12-01 13:05:47 -06:00
Rike-cz cf8a73f0a2 Ensure that fields are defined before attempting to render a specific field (#3812)
Credit to @Rike-cz
2018-09-22 19:22:02 -06:00
Nathan van der Werf 743252c3ff
Merge branch 'develop' into feature/cleanup
# Conflicts:
#	modules/backend/widgets/Form.php
2018-08-29 19:18:01 +02:00
Samuel Georges 2d77565e6c Peer review 52d1388e4e
This uses a simpler approach and leverages improvements to the validation trait
See 574031d3ee
Refs #2489
2018-08-29 12:19:33 +10:00
Luke Towers fcec026dff Add support for checking if nested form fields are required for visual indicator 2018-08-26 12:29:37 -06:00
Nathan van der Werf 8fd16d4db6
Merge branch 'develop' into feature/cleanup
# Conflicts:
#	modules/backend/formwidgets/FileUpload.php
2018-08-24 19:52:54 +02:00
Luke Towers 4078e6a56f Provide inline documentation for the FormWidget events:
Documented the following:
backend.form.beforeRefresh
backend.form.refreshFields
backend.form.refresh
backend.form.extendFieldsBefore
backend.form.extendFields
model.form.filterFields
2018-08-15 21:00:31 -06:00
Nathan van der Werf 8b6f11e6ac Extract child instructions 2018-08-15 19:25:42 +02:00
Nathan van der Werf fbca3bea92 Remove redundant variables 2018-08-15 19:23:12 +02:00
Nathan van der Werf 62c59a4903 Refactor ternary operators to null coalescing operators 2018-08-15 19:15:13 +02:00
Nathan van der Werf a3d7a028b4 Replace is_null with "=== null" comparison 2018-08-15 18:54:46 +02:00
Nathan van der Werf 123145fd54 Remove unnecessary parentheses 2018-08-15 18:49:52 +02:00
Nathan van der Werf 3a918ad200 Remove "null" assignments 2018-08-15 18:33:24 +02:00
Alexander Shapoval 1e7c3691e7 Cast outside field config to array (#3670)
This is necessary to enable the setting of tabs for SECTION_OUTSIDE: http://octobercms.com/docs/backend/forms#form-tab-options. Credit to @ebashu-on-holidays
2018-08-06 10:49:19 -06:00
Luke Towers 014bac1232
Simplify 51b6f64418
Simplifies 51b6f64418 by using the pre-existing HTML array name parsing functionality.
2017-11-02 13:13:08 -06:00
Luke Towers 51b6f64418
Convert field name to dot syntax before checking validation rules
Converts a field name in the form of `model_json_attribute[subproperty]` to the dot syntax version used by validation rules `model_json_attribute.subproperty` for more accurate checking of the validation rules in the form widget.
2017-11-02 12:35:50 -06:00
Samuel Georges cd76f2e04f Field definition should override magic 2017-09-13 14:29:42 +10:00
Samuel Georges c3570ffd7e The event emitter should not be a dependency
Fixes #2938
2017-06-23 08:11:41 +10:00
Samuel Georges 9eb0cc24ae Opens a channel for model to talk with form widget
.. and controller and beyond.
2017-06-17 21:20:34 +10:00
Samuel Georges b841f9e066 {@inheritDoc} -> @inheritDoc 2017-03-16 06:26:14 +11:00
Samuel Georges 5f91c45f79 Implement disabled support for some form widgets
Recompile assets
Fixes #2749 (Media Finder)
Fixes #2750 (File upload)
Fixes #2751 (Rich Editor)
Refs #2724
2017-03-14 13:52:47 +11:00
Samuel Georges e7fa4b832a Rollback 84b533454e
See #2749, #2750 & #2751 on notes for how to better handle this. Put simply, the control of disabled VS previewMode should be given to the individual form widget, as opposed to the spawning parent.
2017-03-14 06:49:33 +11:00
Luke Towers 84b533454e Allow FormWidgets to be disabled like regular FormFields
Adds support for the `disabled` property to FormWidgets so that they will match the behaviour present in regular FormFields. Fixes #2724 and a personal annoyance of mine :)
2017-03-11 02:12:47 -06:00
Samuel Georges 0a2b343047 Simplify system events
This pipes all event calls through a new EventEmitter trait, which substitutes the October Rain event emitter trait. The view event has been moved to this trait also.
Pass some variables by reference to allow multi-extension.
Fixes #2420
2016-12-10 09:02:06 +11:00
Samuel Georges f771887ee5 When refreshing fields, forceFill is a bit too flaky
- Using a proxy field would populate a relation with an array of attributes, this is not good or consistent. Instead the FormModelSaver trait is used to bring the behavior in line with FormController and others. This should improve consistency in the behavior and developer expectations.

- The noticeable difference will be that relations and their values are now set by the postback data where possible. In cases where this is undesirable -- eg: updating a relation triggers proxy fields to update with existing values, when they should seed from the relation instead (desire to lose prior changes) -- the formExtendRefreshData controller override can be used to prune the existing values from the dataset, where they will then be seeded from the model as normal.

- Also the $data property is only rebuilt if it differs from the model. Previously it would corrupt the model-based dataset by converting to an array then back to an object. If the two objects are the same, they will be passed by reference and values will replicate this way.
2016-11-30 07:08:12 +11:00
Samuel Georges 50d3ffb035 Halycon models do not declare forceFill
Only bind purgeable fallback event once (only needed once)
Refs https://github.com/rainlab/translate-plugin/issues/54#issuecomment-256067096
2016-11-05 10:59:53 +11:00
Samuel Georges 7b0f33e9b3 Adds an isNested flag to Form widget
This is useful when a form renders another form inside, specifically the repeater. In these cases the model and data will diverge, and it also provides an opportunity to not apply extension logic to nested form fields.
Fixes #2257
2016-11-05 09:53:23 +11:00
Samuel Georges 9b5851fbd5 Improves exception handling for invalid model resolver
A more specific error message is now shown when trying to resolve a model from an invalid source (eg: an array)
Fixes #2354
2016-09-18 13:44:13 +10:00
Samuel Georges c70db75d38 Pass the data set along with getOptions methods
This is useful when the model is unreliable, because it is not always populated with the relevant data set. This argument is only needed in edge cases, like when using a repeater or other split class<->data scenarios
Refs #2235
2016-07-23 15:16:57 +10:00
Samuel Georges bcff1d3ecd Widget classes are now extendable
Fixes #2078
Fixes #1586
2016-06-15 17:10:46 +10:00
Samuel Georges cb86e655dd Fixes disabled relation nulling value
Just like DatePicker, relation and even regular fields should omitted from the data set
The same logic should apply to hidden fields
Fixes #1827
Recompile assets
2016-05-15 06:47:28 +10:00
Samuel Georges 5400ec7d2d Complete taglist form widget 2016-05-10 06:02:35 +10:00
Samuel Georges 5d27682f25 Create new TagList form widget (Experimental)
Update Select2 to latest
2016-05-08 17:43:21 +10:00
Samuel Georges 0504da41f2 Add hasFields methods
formHasOutsideFields, formHasPrimaryTabs + formHasSecondaryTabs
2016-04-23 05:13:08 +10:00
Samuel Georges 808c8f0ca4 Minor tidy and rollback from #1720 2016-02-13 14:41:17 +11:00
Joshua Wilson 6f3d7a58f2 Phpdoc cleanup for System\Traits
removed in WidgetMaker trait

phpdoc cleanup of backend traits and classes

Minor fix for cases when file is not found
2016-02-13 14:06:50 +11:00
Samuel Georges e367febb93 Roll back some stuff from #1704 2016-02-13 13:18:48 +11:00